Format and Indent XML
Turn a one-line SOAP response, sitemap or config file into neatly indented XML, or strip the whitespace back out. The document is checked for well-formedness first, and CDATA sections, comments and attribute values are left exactly as written.
How to format XML
- Paste XML or choose a file such as .xml, .svg, .rss or .xsd.
- Choose Pretty-print and an indentation of 2 spaces, 4 spaces or tabs — or choose Minify and optionally remove comments.
- If the XML is not well-formed, fix the error shown with its line and column; otherwise the result updates instantly.
- Copy the formatted XML or download it as a file.
Supported formats
- Input
- XML, SVG, RSS/Atom, XSD/XSL
- Output
- XML
- Maximum size
- 20 MB per file (limited by your device's memory)
Whitespace that is kept on purpose
Text inside an element that contains only text is never re-wrapped, because whitespace there can be meaningful data. Elements marked xml:space="preserve" are copied verbatim, including their children. Only whitespace between tags — and around text in mixed content — is adjusted. For a full structural report and namespace list, use the XML Validator; for JSON documents, the JSON Formatter does the same job.
Benefits
- Never alters attribute values, entity references, CDATA content or processing instructions.
- Rejects malformed input with a pinpointed error instead of producing misleading output.
- Shows input and output size, which is handy when minifying feeds or SVGs.
Limitations
- In mixed content (text interleaved with tags, as in XHTML paragraphs) leading and trailing spaces around text are trimmed when pretty-printing.
- Long start tags are not wrapped across lines; each tag keeps all its attributes on one line.
Privacy and security
Formatting runs entirely in this tab using the browser's built-in XML parser and a local pretty-printer. Your XML is not uploaded, and no external DTDs or entities are fetched.
Read our privacy policy for details about the site as a whole.
Frequently asked questions
Does formatting change my data?
Pretty-printing only changes the whitespace between tags. Text-only elements, CDATA and xml:space="preserve" blocks are untouched. In mixed content, whitespace at the edges of text runs is trimmed, which can matter for document-style XML.
Can it format HTML?
Only XHTML that is well-formed XML. Ordinary HTML allows unclosed tags such as <br>, which XML rejects — use the HTML Formatter for that.
Why is minified XML still showing line breaks?
Line breaks inside text content or attributes are part of the data and are kept. Minifying removes only the whitespace that sits between tags.