01 / Format
Indented by level
Each element on its own line, indented by depth; short text stays on one line with its tags.
Free tool
Paste XML or drop a file and it is checked and indented as you type. A mistake is explained in plain words and marked on its line, and common slips like a bare & can be fixed with one click. The result is coloured and searchable, as formatted XML, minified XML or JSON. Mixed text, the DOCTYPE, comments and CDATA are kept. Big files stay quick, and nothing is uploaded.
Need a custom tool, app or website? Contact us →This file is big, so it is kept out of the text box to keep the page quick. The result is on the right.
The formatted XML shows here.
Paste on the left, open a file, or press Example.
Options
Keys
Your XML is read by your browser's own parser. It is never uploaded or saved. Only your settings are remembered on this device.
Clean XML
01 / Format
Each element on its own line, indented by depth; short text stays on one line with its tags.
02 / Minify
Spaces between tags removed, for sending or storing.
03 / Check
Your browser's XML parser finds the first mistake. The line is marked and the message is in plain words.
Guide
An XML formatter takes XML that is squashed onto one line, or indented in a messy way, and rewrites it so each element sits on its own line, indented by how deep it is. This one can also minify XML back onto one line, or simply check whether it is well formed. The checking is done by your browser's own XML parser, so if the file will not parse here, it will not parse in most other software either.
If the XML has a mistake, the result side explains it, shows the lines around it, and marks the line in the input in red. Show in the input puts the cursor right there.
Formatted is for reading. Each element gets its own line, indented by how deep it is. An element with only a short piece of text stays on one line, so <title>Dune</title> is not split over three lines. With Attributes set to one per line when a tag is long, a tag with many attributes is split so each one sits on its own line once the tag passes 100 characters.
Minified is for machines. It removes the line breaks and indentation between tags. Text inside elements is kept exactly as it was, spaces included. Tick Remove comments when minifying to drop comments too.
JSON turns the XML into JSON. Attributes become keys that start with @, such as "@id": "1". Text next to attributes or child elements goes in "#text". Elements with the same name become a list. Values stay as text, so 9.99 becomes "9.99" and nothing is lost.
The Check button tests whether XML is well formed: every tag is closed, tags nest properly, there is one root element, attribute values are quoted and special characters are escaped. That is the basic grammar every XML file must follow.
Valid XML goes one step further: it also follows a schema (an XSD or DTD) that says which elements are allowed, in what order, and what their values can be. This tool does not test against a schema. A file can pass Check here and still be rejected by a system that expects certain elements.
| Problem | Example | Fix |
|---|---|---|
| Closing tag does not match | <name>Ann</Name> | XML is case sensitive. Make both tags exactly the same. |
| Tag never closed | <item>Pen | Add </item>, or write an empty element as <item/>. |
| Tags overlap | <b><i>hi</b></i> | Close the inner tag first: </i></b>. |
| Bare ampersand | <co>Smith & Sons</co> | Write & instead of &. |
| Unquoted attribute | <book id=1> | Quote it: id="1". |
| Two root elements | <a/><b/> | Wrap everything in one outer element. |
| Something before the declaration | A blank line or space before <?xml | The declaration must be the very first thing in the file. |
The line and column in the error point to where the parser gave up, which is often just after the real mistake. If the error is about a closing tag, look back up the file for the opening tag that was never closed.
When the XML does not parse, the error box offers a fix if one of these is in the file. Each fix is listed by what it changes, and Cmd+Z (Ctrl+Z on Windows) in the input undoes it.
and © exist in HTML, not XML. They become   and ©, which every XML reader knows.<p>Hello <b>there</b></p>, stay on one line exactly as written, so no spaces between words are lost. Elements marked xml:space="preserve" are kept as written too.©, is written as the character itself.The result is drawn a screen at a time, so files of many megabytes scroll smoothly and search covers the whole file. A file over 3 MB is kept out of the input box, which would make typing slow, and its result shows on the right. Press Edit it here anyway if you need to change it. Reading a large file takes a moment, because the whole file has to be parsed first.
Cmd+Enter formats, Cmd+Shift+Enter minifies, Cmd+S downloads, Cmd+Shift+C copies and / jumps to search. On Windows, use Ctrl for Cmd. Your indent, layout and other settings are remembered on this device. The XML itself is never stored.
macOS includes a command line tool called xmllint. Open Terminal and run xmllint --format file.xml to print an indented copy, or xmllint --noout file.xml to check a file and see only the errors. It is handy for files too large to paste into a browser.
Mac property list files (.plist) are often saved in a binary form, not as text. If a .plist opens here as garbled characters, convert a copy to XML first with plutil -convert xml1 copy.plist. That command rewrites the file you name, so run it on a copy.
Working with JSON instead? Use the JSON formatter. To see exactly what changed between two versions of a file, paste both into the diff checker.
Questions
Paste it or drop the file. It is formatted as you type, and you can download or copy the result.
Paste it. The result side explains the first error in plain words with its line and column, and the line is marked in red in the input. Show in the input puts the cursor on it.
For a few common slips, yes: a bare &, HTML names like , text before the declaration and two root elements. Each fix is offered only when it applies, and can be undone. Other mistakes, like a missing closing tag, need you to decide where it goes.
Yes, and the XML declaration and processing instructions too. Minify can drop comments if you tick that option.
Yes. Press JSON above the result. Attributes become keys starting with @, repeated elements become lists, and values stay as text.
Yes, any well-formed XML.
No. It is read by your browser's own XML parser in this tab. Only your settings are remembered on this device.
Well formed means the XML follows the basic rules: closed tags, proper nesting, one root, quoted attributes. Valid means it also matches a schema such as an XSD or DTD. This tool checks well formed XML only.
Usually the file has more than one top level element, or stray text after the last closing tag. XML allows only one root element. The Wrap it all in one <root> fix does that for you.
Elements, attributes and text stay the same. In the formatted view, spaces at the start and end of text-only elements are trimmed. Mixed text and tags, and xml:space="preserve", are kept exactly.
There is no set limit. Files of many megabytes work; the limit is your computer's memory. Very large files take a moment to read.