XML formatter: beautify, indent and minify XML, free and private
An XML formatter re-indents XML so its structure is easy to read, or squeezes it onto fewer lines. To format XML free and privately, paste it into Input XML or click Upload XML File, choose an Indentation and read the result under Formatted XML, which updates as you type. Then use Copy or Download. The formatting runs in your browser and nothing is uploaded; you can check that in the Network tab of DevTools.
Only the whitespace between elements changes. An element that holds text, including mixed content such as <p>Hello <b>world</b></p>, is kept on one line exactly as written, so formatting never alters your data. This is the approach the command-line tool xmllint takes when it formats a file. If the XML is not well-formed, you see the parser's message with the line and column instead of output.
To check XML without reformatting it, use the XML validator. To move data between formats, try the XML to JSON converter or its reverse, the JSON to XML converter.
Table of Use: XML in, formatted XML out
| You paste | Setting | You get |
|---|---|---|
| <root><item id="1">A</item><item id="2">B</item></root> | 2 spaces (default) | <root> <item id="1">A</item> <item id="2">B</item> </root> |
| <root><a><b>x</b></a></root> | 4 spaces | <root> <a> <b>x</b> </a> </root> |
| <root> <a>1</a> <b> <c>2</c> </b> </root> | Minify (no indentation) | <root><a>1</a><b><c>2</c></b></root> |
| <p>Hello <b>world</b></p> | Any: mixed content is kept as written | <p>Hello <b>world</b></p> |
| <root><a></a><b x='1'/></root> | 2 spaces: standard form | <root> <a/> <b x="1"/> </root> |
| <root><!-- note --><s><![CDATA[a < b]]></s></root> | Keep comments and Keep CDATA sections ticked | <root> <!-- note --> <s><![CDATA[a < b]]></s> </root> |
| <root><s><![CDATA[a < b & c]]></s></root> | Keep CDATA sections unticked | <root> <s>a < b & c</s> </root> |
| <root><a></root> | Any: not well-formed | Not well-formed XML (line 1, column 17): Opening and ending tag mismatch: a line 1 and root. (Chrome's wording) |
Formatted XML is also the easiest to compare. Paste an old and a new version into the text diff tool and the changed elements stand out line by line. For JSON payloads, the JSON formatter does the same job.
Features
- Formats as you type. No Format button; Formatted XML updates with every change.
- Indentation. 2 spaces (default), 4 spaces, Tab, or Minify (no indentation).
- Keep comments, Keep CDATA sections and Show line numbers. All three are ticked by default. Unticking Keep CDATA sections converts each one to escaped text.
- Syntax highlighting. Tags, attribute values, comments and CDATA sections are shown in different colours, which makes the structure easier to scan.
- Search in formatted XML. Highlights every matching line and says how many matched.
- Upload XML File. Accepts .xml, .xsd, .xsl, .xslt, .svg, .rss, .atom, .plist and .config files, reading the encoding from the byte-order mark or the XML declaration.
- Prolog preserved. The XML declaration, DOCTYPE, top-level comments and processing instructions such as xml-stylesheet stay in place.
- Clear errors. Not well-formed XML is reported with the line and column and the text of the offending line.
- Undo, Redo, Copy, Download and Clear. Download is named formatted.xml, or after your uploaded file with .formatted added.
It does not validate against a schema, run XSLT or XPath, sort attributes or wrap long lines. Entity references that depend on an external DTD cannot be read by a browser, so the tool keeps them as references or, when it cannot, explains what to replace instead of silently deleting text.
How to format XML, step by step
- Paste or type your XML into Input XML, or click Upload XML File and choose a file.
- Choose Indentation: 2 spaces, 4 spaces, Tab, or Minify (no indentation).
- Untick Keep comments or Keep CDATA sections if you want them removed or converted, and untick Show line numbers if they get in the way.
- Read Formatted XML. Type in Search in formatted XML to highlight lines that contain a word.
- If a Not well-formed XML message appears, go to the line and column it names, fix the tag or character, and the output returns.
- Click Copy for the clipboard or Download for a file. Undo and Redo step back through your edits, and Clear starts over.
Who can use it
- Developers reading API responses, SOAP messages and .config files, then reusing the data through the XML to JSON converter.
- SEO specialists and webmasters inspecting an RSS feed or a sitemap.xml, for example one made with the sitemap generator.
- Front-end developers tidying SVG files before turning them into CSS with the SVG to CSS converter, and markup with the HTML beautifier.
- Integration and QA engineers comparing the XML two systems exchange.
- Students learning how elements nest, with indentation and line numbers showing the depth.
FAQs
How do I format XML online?
Paste your XML into Input XML, or click Upload XML File. The indented version appears under Formatted XML as you type, using 2 spaces by default. Choose 4 spaces, Tab or Minify (no indentation) in the Indentation menu, then click Copy to put the result on your clipboard or Download to save it as an .xml file. There is no Format button to press.
How do I minify XML?
Choose Minify (no indentation) in the Indentation menu. The whitespace between elements is removed, so the document is written without line breaks or indentation. Text inside elements is never touched, so the minified file means exactly the same as the original. The result is headed Minified XML, and a downloaded copy is named with .min before .xml.
Does formatting change my XML data?
Only the whitespace between elements changes. An element that contains text, including mixed content such as <p>Hello <b>world</b></p>, is written on one line exactly as it was. A few things are written in an equivalent standard form: empty elements become <a/>, attribute values use double quotes, and character and entity references are written out as the characters they stand for.
Why does the formatter say "Not well-formed XML"?
The formatter must parse your XML before it can lay it out, so a syntax error stops it and shows the message, the line and column, and the line itself. Common causes are a tag that is not closed or does not match its opener, an unescaped & or <, an unquoted attribute value and more than one root element. The wording comes from your browser's parser, so it differs slightly between browsers.
Are comments, CDATA, the DOCTYPE and the XML declaration kept?
Yes, by default. Untick Keep comments to remove comments. Untick Keep CDATA sections and each one becomes escaped text, so <![CDATA[a < b]]> turns into a < b. The DOCTYPE and processing instructions stay in place. If the declaration names an encoding other than UTF-8, the output says UTF-8 instead and a notice tells you, because Copy and Download produce UTF-8.
Does it validate XML against an XSD or DTD?
No. It only checks that the XML is well-formed, because it uses your browser's XML parser, which does not apply a schema or a DTD. A schema-valid file and a merely well-formed file are formatted the same way. For a well-formedness report with a document summary and one-click fixes for common mistakes, use the XML validator.
Is my XML uploaded to a server?
No. Formatting runs in your browser with its built-in XML parser, and an uploaded file is read on your device. Nothing is sent to ZipConvert; open the Network tab in DevTools while you paste or upload to check. There is no fixed size limit, only your browser's memory. The on-screen preview stops at 3,000 lines, while Copy and Download include everything.