Format, minify and check XML
Pretty-print or minify XML and check that it is well-formed, with the line and column of any error.
0 / 2,000,000 characters · Updates as you type.
XML still runs a lot of the world: sitemaps and RSS feeds, SOAP and banking APIs, e-invoices, Android layouts, Office documents, SVG and countless configuration files. It usually arrives as one long line or with indentation that no longer matches the nesting. This formatter puts each element on its own line, indents children under their parent, keeps short text-only elements such as <title>Report</title> on one line, and leaves the XML declaration, comments, CDATA sections and doctype intact.
Before formatting, the document is checked for well-formedness: every start tag has a matching end tag in the right order, attribute values are quoted and not repeated, ampersands are written as entities, and there is exactly one root element. If anything is wrong you get a message such as "Expected </item> but found </list>" with the line and column, and the offending line shown with a caret, which is often faster than reading a stack trace from the program that rejected the file. The facts panel shows the root element, the number of elements and the deepest nesting.
Minify mode does the opposite: it removes whitespace between tags while keeping text content exactly as written, and can drop comments too. Note that well-formed is not the same as valid: this tool does not check a DTD or XML Schema, so a file can pass here and still be rejected by a system that expects particular elements. The formatter is a small purpose-built parser that runs in your browser; nothing is uploaded.
How to use it
- Paste the XML document into the input.
- Choose Pretty-print (and the indentation) or Minify.
- Fix any error using the line and column shown, then check the facts panel.
- Copy the result or download formatted.xml.
Frequently asked questions
Does it validate against a schema (XSD or DTD)?
No. It checks well-formedness, the rules every XML document must follow. Schema validation needs the schema file and a validating parser.
Will formatting change my data?
Pretty-printing adds indentation and trims whitespace at the start and end of text-only elements. If your format treats that whitespace as meaningful (rare, but possible with xml:space="preserve"), use Minify or keep the original.
Why is "&" an error?
In XML an ampersand starts an entity such as & or ©. A bare & (for example in a URL query string) must be written as &.
Are namespaces supported?
Yes. Prefixed names such as soap:Envelope and xmlns declarations are kept exactly as written.
Can I format a sitemap or RSS feed?
Yes, both are XML. To create a sitemap from a list of URLs, use the sitemap generator.
Related tools
- Format and beautify HTMLBeautify minified or messy HTML with consistent indentation, including inline CSS and JavaScript.
- Format, beautify or minify JSONPretty-print or minify JSON with 2-space, 4-space or tab indentation and optional key sorting.
- Generate a sitemap.xml from a list of URLsTurn a list of URLs into a valid sitemap.xml with lastmod, changefreq and priority options.
- Format and beautify CSSUnminify and beautify CSS: one declaration per line, clean indentation, readable media queries.
- Format and beautify JavaScriptBeautify minified or messy JavaScript and JSON-like code with your choice of indentation and brace style.
- Minify JSONStrip every unnecessary space and line break from JSON and see how many bytes you saved.