How to format XML
- 1Paste your XML into the Input panel, or click Upload to open an .xml, .svg, .rss or .xsd file from your computer.
- 2Check the status next to Input. If the XML is not well-formed you will see the line and column of the first problem, such as a closing tag that does not match.
- 3Choose an indent of 2 spaces, 4 spaces or a tab, then click Format to pretty print the XML. Click Minify instead to remove the indentation and line breaks.
- 4Tick Remove comments if you want them stripped from the output, then copy the result or click Save to download formatted.xml.
What an XML formatter and validator does
XML that comes out of a build tool, an export or a SOAP response is often a single long line. That is fine for a parser, but impossible to read when you are hunting for a missing element or a wrong attribute. This XML formatter adds line breaks and consistent indentation, so the nesting of elements is obvious, and it keeps text, CDATA sections, comments and processing instructions exactly as they were.
Formatting only works on XML that is well-formed, so the tool doubles as an XML validator. It checks the rules a parser enforces: every opening tag needs a matching closing tag in the right order, attribute values must be quoted and unique within an element, a bare ampersand must be written as &, and there can be only one root element. When one is broken, the message names the problem and the line and column where it was found. Well-formed does not mean valid against a schema, so this checks syntax, not an XSD or DTD.
Minifying is the reverse job. The XML minifier removes the whitespace between elements and, optionally, the comments, which makes a payload smaller to send or embed. Whitespace inside text is left alone, because in XML it can carry meaning.
The parser is built into the page and runs in your browser, so you can safely paste configuration files, invoices and API responses that you would not want to send to a third-party server.
When developers reach for it
Reading SOAP and API responses
Paste a one-line response from a SOAP service or REST endpoint, then format XML online with a clean XML pretty print to find the element you need.
Fixing broken config files
Validate XML online for a pom.xml, web.config or Android manifest and jump to the exact line of a mismatched tag.
Cleaning up feeds and sitemaps
Check an RSS feed or sitemap before you publish it, and format it so changes show up clearly in a code review.
Shrinking XML payloads
Minify exported data or an SVG before embedding it, removing indentation and comments to cut the size.
Frequently asked questions
Is my XML uploaded anywhere?
+
No. Parsing, validating, formatting and minifying all happen in your browser. Nothing is sent to a server, so it is safe for private data.
Is this XML formatter online free to use?
+
Yes. The tool is free, needs no sign-up and has no fixed size limit beyond what your browser can handle.
What does the XML validator check?
+
It checks that the XML is well-formed: matching and correctly nested tags, quoted and unique attributes, valid entities, a single root element and a proper XML declaration. It does not validate against a DTD or XSD schema.
Why does it say my XML is not well-formed?
+
The usual causes are an unclosed or mismatched tag, an unquoted attribute value, a stray ampersand or less-than sign in text, or two root elements. The error message gives the line and column where the parser stopped.
Does formatting change my data?
+
Only whitespace between elements changes. Element names, attributes, text, CDATA sections and comments are kept as they are, although text that sits next to child elements is trimmed and moved to its own line.
Can I use it as an XML beautifier for SVG or RSS?
+
Yes. SVG, RSS, Atom, XSD, XHTML and similar files are XML, so you can upload them or paste them in and format them the same way.
What is the difference between formatting and minifying XML?
+
Formatting adds indentation and line breaks for people to read. Minifying removes optional whitespace, and comments if you choose, to make the file as small as possible. The data is the same either way.
Related tools
XML to JSON Converter
Convert XML to JSON with attributes and repeated elements handled, or convert JSON back to XML. Options for prefixes, arrays and types; nothing is uploaded.
JSON Formatter
Format and beautify JSON data with syntax highlighting and validation.
SQL Formatter
Format and minify SQL queries with standard, MySQL or PostgreSQL syntax. Choose keyword case and indent. Queries stay in your browser.
Diff Checker
Compare two texts or code files and see added, removed and changed lines highlighted side by side or inline, down to the character. Private and in-browser.