Developer tool
XML Formatter
Format and validate XML: check that a document is well-formed, see the parser's error if it is not, and indent it with two spaces, four spaces or tabs.
Your file never leaves your device.
Runs locally in your browser
Your text is not uploaded.
Simple steps
How it works
- 01
Paste XML into the editor.
- 02
Choose indentation and format the document.
- 03
Copy valid formatted XML or review the parser error.
Checked first, then indented
Before formatting, the browser's XML parser reads the whole document. If it is not well-formed, for example a tag is never closed, tags overlap as in <b><i></b></i>, an attribute value has no quotes, or a bare & is not written as &, you get an error and nothing is changed.
The formatter then puts each tag on its own line and indents child elements by two spaces, four spaces or a tab. Comments, CDATA sections, processing instructions and the DOCTYPE are kept, and the content of script, style and pre elements is not indented further.
What to check after formatting
Each piece of text between tags is also moved onto its own line, so <name>John</name> becomes three lines. That is easy to read, but a program that reads text values exactly will now see line breaks and spaces around John. Use the formatted version for reading and reviewing, and keep the original file for processing, especially for mixed content where text and tags share a line.
Well-formed is not the same as valid
A well-formed document follows the syntax rules of XML. A valid document also matches a schema (XSD) or DTD that says which elements may appear where. This tool checks the first only, so a document that passes here can still be rejected by a system that validates against its schema.
Good to know
Frequently asked questions
Does formatting validate XML?
Yes. A browser XML parser checks that the document is well-formed before formatting.
Does it validate against an XSD or DTD?
No. It checks syntax only; schema validation is not included.
Can I choose indentation?
Yes. Select two spaces, four spaces, or tabs.
Will formatting preserve every whitespace node?
Formatting normalizes indentation between markup; review mixed-content XML carefully.
Is XML uploaded?
No. Parsing and formatting happen in your browser.