XML Formatter
Indents and validates XML.
This tool runs on JavaScript. To use it, turn on JavaScript in your browser and reload the page.
MAKE THE XML TREE VISIBLE.
The XML Formatter makes an XML file written on one line or indented untidily readable. Every element is put on its own line and indented by 2 spaces, 4 spaces or a tab according to its nesting level; unnecessary blank lines are dropped. During the same run it is also checked whether the file is valid XML: if there is an unclosed tag or a bad character, the tool stops with an error message. Besides XML, SVG, XHTML, RSS and XSL files can be uploaded.
For safety, XML files containing a DTD or an ENTITY definition are not processed. Those definitions are the door to the “billion laughs” attack that fills the server's memory and to XXE attacks that make it read outside files; they are not needed for formatting either. If you have such a file, take the DOCTYPE section out and try again. While indenting, the spaces between elements are rearranged; in mixed-content documents where whitespace carries meaning, check the result. Files up to 32 MB can be uploaded. The root element and the element count of the output are written on screen. You can upload up to 20 files at once; they are all processed with the same settings, and several files download as a single ZIP.
From start to finish
- Upload your XML file. Drag an XML, SVG, XHTML, RSS, XSL or TXT file in or select it.
- Choose the indentation. 2 spaces is the common choice; pick 4 spaces or a tab according to your team's rule.
- Format and download. If it is valid, download the formatted file. If there is an error, look at the line in the message and fix it.
Frequently asked questions
I got the warning “XML containing a DTD or ENTITY is not processed”.
There is a <!DOCTYPE …> section at the start of the file. For safety those sections are not processed. Delete the section and upload again; the formatting result is not affected.
Can I format my SVG file?
Yes. An SVG is an XML file; the indented version is far easier to edit and to see differences in. The appearance does not change.
Can I convert XML to JSON?
This tool only formats and validates. For configuration files there is the “YAML → JSON” tool; conversion from XML to JSON is not offered at the moment.
Does my file stay on the server?
No. Your file reaches the server only to be processed and is deleted when the job is done; the output is deleted too once you download it and leave the tool. You don't need an account, a name or an email address, and your files are never sent to a third-party service. It is free to use: we set no hourly or daily quota on the number of jobs, we don't make you watch an ad before processing, and we add no watermark to the output.
Other File tools
RUPO Studio