XML Formatter
Paste or upload XML to instantly format, validate or minify it. Everything runs in your browser — your data never leaves your device.
Read the guide: How to format XMLInput
Formatted XML
Your XML is processed to provide formatting and validation. XML contents are not included in analytics.
How the XML Formatter works
- Your XML is parsed using the browser's built-in DOMParser, which checks the document is well-formed.
- For formatting, the parsed document is re-serialised with your chosen indentation (2 spaces, 4 spaces or tabs).
- For minifying, it is re-serialised with no unnecessary whitespace while preserving text content, comments and CDATA.
- If parsing fails, the error is shown with the line and column where the problem was found.
See also: JSON Validator, JSON Formatter and JSON Minifier.
Examples
Compact XML
<?xml version="1.0" encoding="UTF-8"?> <catalog><book id="1"><title>Example</title><author>John</author></book></catalog>
Nested elements
<root>
<items>
<item id="a">Value</item>
</items>
</root>Useful tips
- Use Validate first on broken XML to find the error before formatting.
- Choose 2 spaces, 4 spaces or tabs for formatting — the data stays the same.
- Upload a .xml file to format it instantly without pasting.
- Minify XML to create compact output for production use.
Frequently asked questions
What is an XML Formatter?+
An XML Formatter takes XML text and adds consistent indentation and line breaks to make it easier to read. It parses the XML, checks it is well-formed, and re-serialises it with your chosen indentation (2 spaces, 4 spaces or tabs).
How do I format XML?+
Paste your XML into the editor or upload a .xml file, then click Format XML. The tool validates the XML first and, if well-formed, produces neatly indented output you can copy or download.
How do I beautify XML?+
Formatting and beautifying XML are the same thing. Click Format XML to add indentation and line breaks that make the structure easier to read. You can choose 2 spaces, 4 spaces or tabs for indentation.
Does formatting XML change the data?+
No. A proper formatter preserves the XML structure, attributes, namespaces, comments, CDATA blocks and text content. Only the presentation whitespace (indentation and line breaks between elements) is changed. Meaningful whitespace inside text nodes is preserved.
Can I format an XML file?+
Yes. Click Upload XML File and choose a .xml file. The file is loaded as text into the editor and you can format, validate or minify it instantly. The maximum file size is 5 MB.
What is XML pretty printing?+
XML pretty printing is another name for XML formatting. It adds whitespace and indentation to compact or unformatted XML so the nesting structure is visible and the document is easier to read and debug.
What is the difference between XML formatting and XML validation?+
Validation checks whether your XML is well-formed (correct syntax, matching tags, proper nesting). Formatting re-indents valid XML for readability. A formatter should validate first — if the XML is not well-formed, it cannot be formatted.
Can I minify XML?+
Yes. Click Minify XML to remove unnecessary formatting whitespace while preserving the XML content, comments, CDATA, attributes and namespaces. The result is compact XML that is still valid.
Does XML support comments?+
Yes. XML comments are written as <!-- comment text -->. The XML Formatter preserves comments in both formatted and minified output.
Can XML contain CDATA?+
Yes. CDATA sections (<![CDATA[ ... ]]>) allow you to include text that would otherwise need escaping, such as JavaScript or HTML. The XML Formatter preserves CDATA blocks without altering their content.
Is my XML stored when I use the formatter?+
No. Your XML is processed entirely in your browser and is never uploaded or stored. We do not include your XML content in analytics.
Related guides
How to format and validate JSON
JSON is the lingua franca of the modern web, but a single stray comma can break an entire API response. This guide shows you how to format and validate JSON quickly, what the most common errors look like, and how to fix them — all using a free tool that runs entirely in your browser.
How to convert JSON to CSV
JSON is great for APIs, but spreadsheets still rule for analysis. This guide explains how to turn JSON into a clean CSV file, how nested values are handled, and the common pitfalls to avoid — all using a free tool that runs entirely in your browser.
How to validate JSON
A single stray comma can break an entire API response. This guide explains what JSON validation is, the most common syntax errors and how to fix them — all using a free tool that runs entirely in your browser.
How to minify JSON
Minified JSON is smaller, faster to transfer and just as valid as the formatted original. This guide explains what minification does, how it differs from compression, and why your data stays exactly the same — all using a free tool that runs entirely in your browser.
What would you like to do next?
JSON Validator
Validate JSON online, find syntax errors, format and minify JSON with clear error messages and line and column information.
JSON Formatter
Format, validate and minify JSON instantly — all in your browser.
JSON Minifier
Minify JSON online by removing unnecessary whitespace while preserving your data. Validate, compress, copy and download compact JSON.