Home/Tools/Developer Tools/XML Formatter

XML Formatter & Validator

Developer Tools
Input
Output

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

What the XML Formatter does

The XML Formatter indents XML so it can be read, minifies it to one line for transport, and checks that it is well-formed, pointing at the exact line and column of the first problem with a plain explanation. It handles declarations, comments, CDATA, processing instructions and DOCTYPE, and offers attribute wrapping and comment stripping. It is for developers working with SOAP, RSS, SVG, config files and data feeds. It does not validate against a DTD or XSD.

How to use it

  1. 1Paste XML into the Input panel or upload a .xml, .svg, .rss or .plist file.
  2. 2Pick an indent of 2 spaces, 4 spaces or a tab, and any of the switches: wrap attributes, strip comments, collapse empty tags.
  3. 3Press Format (or Cmd/Ctrl+Enter) for indented output, Minify for a single line, or Validate to check well-formedness without changing anything.
  4. 4If the document is not well-formed, the red box shows the line, the column, what is wrong and the offending line under a caret.
  5. 5Copy the result or download it as .xml.

Options explained

Indent: 2 spaces, 4 spaces or tab
Match your project's convention. Two spaces is the most common for config files and web; four for Java and .NET codebases; tabs when the file is edited by people with different indent preferences.
Wrap attributes
Puts each attribute on its own line, indented under the tag, when an element has more than one. Use it for SVG paths, Spring beans and Android layouts with long attribute lists; leave it off for compact documents.
Strip comments
Removes <!-- --> comments from the output, for files that will be shipped or embedded. The input is untouched.
Collapse empty tags
Writes <item></item> as <item/>. Both are equivalent XML; some systems prefer one form. Elements that were already self-closing stay that way either way.
Minify
Removes indentation and whitespace-only text between tags, keeping comments (unless stripped), CDATA and text content exactly. Use it for request bodies and embedded XML.
Validate
Checks well-formedness only: matching tags, quoted attributes, one root element, escaped ampersands and angle brackets, no duplicate attributes. It does not check element names or order against a schema.

Common problems and limits

Input is limited to 10 MB. Very large feeds should be processed with a streaming tool such as xmllint --format on the command line.

DTD and XSD validation are not supported. 'Well-formed' means the syntax is correct, not that the document matches a schema. Entities declared in an internal DOCTYPE subset are accepted without being expanded.

Whitespace-only text between elements is dropped when formatting and minifying, which is what every XML pretty-printer does. Whitespace inside text nodes is collapsed to single spaces; use CDATA for text where spacing matters.

Mixed content (text and child elements in the same parent, as in XHTML paragraphs) is laid out one node per line, which is correct XML but can look different from the source.

Namespaces are checked syntactically (prefix:name) but prefixes are not resolved against xmlns declarations.

Who uses it

  • Backend developers: Read a SOAP response or a legacy integration payload that arrived as one long line, and find the unclosed tag the other side's parser complained about.
  • Front-end developers and designers: Clean up an exported SVG: wrap attributes, strip editor comments, collapse empty groups.
  • DevOps and Java/.NET engineers: Format pom.xml, web.config, Android manifests and Spring XML to the team's indentation before a commit.
  • Ecommerce teams: Check a Google Merchant Center or RSS product feed is well-formed before the next crawl, with the exact line of a stray ampersand.
  • Data and content teams: Make a sitemap, podcast RSS or DocBook export readable to review it.

Frequently asked

How do I format an XML file?

Paste its contents or upload the file above, choose the indentation and press Format. The output is the same document with one element per line and nested elements indented. Download it or copy it back into your editor.

How can I beautify my XML code?

Beautifying is the same as formatting: consistent indentation, one tag per line, optional attribute wrapping. Use the Format button; turn on Wrap attributes for elements with many attributes.

How do I convert XML into a readable format?

Format it here with 2- or 4-space indentation. If the goal is to read the data rather than the markup, the structure is clearest with Collapse empty tags on and comments stripped.

Is there a free online XML formatter?

This one is free, needs no account, runs in your browser and handles files up to 10 MB. It also validates well-formedness and minifies.

Is Excel an XML format?

Modern Excel files (.xlsx) are ZIP archives containing XML parts (Office Open XML), and Excel can also open and save plain XML data with a schema map. You cannot paste an .xlsx into a text tool directly, but the XML parts inside it can be formatted here.

How do I edit an XML file online?

Paste the file here, format it so the structure is clear, make your edits in the input panel, then press Validate to confirm it is still well-formed and download the result.

How do I open an XML file online?

Any browser opens an .xml file and shows the tree, but it will not indent it or explain errors. Upload the file to this page to see it formatted, or to find out why the browser reports a parse error.

What does 'not well-formed' mean?

The document breaks an XML syntax rule: a tag is not closed or closed in the wrong order, an attribute value is unquoted, an & or < appears unescaped in text, there is more than one root element, or an attribute is repeated. The error box names the rule and the line and column.

Automation: an MCP tool format_xml(text, indent, minify) → text and an n8n node are planned for this tool.