XML formatter and validator
Paste XML to check it, tidy it or squeeze it. Ctrl+C copies the result.
Private: your files never leave this deviceNothing is uploaded or stored on a serverWorks right here in your browserPretty print puts each tag on its own line. Short empty tags turns <a></a> into <a/>.
Need JSON instead? Convert XML to JSON
How to format and check XML
Paste or open
Paste XML into the Input pane, press Open to pick an .xml file, or drop it on the pane. Sample loads a small shop price list.
Pick the style
Pretty print indents each level with the indent you choose; Minify puts it all on one line. Choose short empty tags and whether to keep comments. Mistakes show their line and column.
Copy or download
Press Copy, or Ctrl+C with nothing selected, to copy the result. Download saves it as an .xml file.
Good to know
- Mixed text and tags, such as a sentence with a bold word, gets each piece on its own line when pretty printed. Use Minify or xml:space="preserve" to keep such text exactly.
- Files over 2 MB stay out of the editor; a worker reads them from disk so the page does not freeze. Only the first 1 MB of the result is drawn, Copy and Download use all of it.
- The header line, such as <?xml version="1.0"?>, and a DOCTYPE with its entity list are kept at the top.
- Entities such as & stay as they are; nothing is decoded or encoded.
Questions people ask
What does Pretty print change?
It puts each element on its own line and indents it by its depth. An element that holds only text stays on one line, like <name>Ravi</name>. Text, attribute values, comments and CDATA sections are kept as they are.
What does Minify remove?
Only the spaces and line breaks between tags, extra spaces inside tags and, if you untick Keep comments, the comments. Text inside elements is never changed.
Why does it say my XML is invalid?
Every tag must be closed, tags must close in the right order, attribute values need quotes and there must be one outer element. The error names the line and column; Go to error jumps there.
Can I keep spacing inside an element exactly?
Yes. Give the element xml:space="preserve" and it is copied exactly as written, with everything inside it.
Is my file uploaded?
No. Checking and formatting run in a background worker inside your browser. Nothing is sent to a server.