XML formatter
Paste XML to pretty-print it, minify it, check it's well-formed or convert it to JSON. Nothing leaves your browser.
What the XML formatter does
- Format puts each element on its own line, indented by depth. Elements that only hold text stay on one line, and mixed content like
<p>Some <b>bold</b> text</p>is kept as written, so no text changes. - Minify removes the whitespace between tags (and comments, if you like) for the smallest file. Text, CDATA and attribute values are kept, and so is whitespace inside text-only elements, mixed content and xml:space="preserve".
- Validate runs every time: if the XML isn't well-formed (an unclosed tag, an unquoted attribute, an undefined entity like
), you get the line and column. - To JSON converts attributes to
"@name", repeated elements to arrays and text-only elements to plain values.
Common XML errors
| Error | Fix |
|---|---|
| Unexpected entity: nbsp | XML only knows & < > " '. Use   instead. |
| Tag doesn't match | Every <tag> needs a matching </tag>, closed in reverse order. |
| Only one root element | Wrap everything in a single outer element. |
| Unquoted attribute | Attribute values need quotes: id="1". |
| A bare & in text | Write &, or wrap the text in <![CDATA[ ... ]]>. |
Questions
Is my XML uploaded?
No. Formatting, validation and conversion happen in your browser.
Does it validate against an XSD schema?
No. It checks that the XML is well-formed (correct syntax), which catches most mistakes. Schema validation needs the schema and a validating parser.
Will formatting change my data?
Whitespace-only text between tags is removed or re-indented, and Format trims text-only elements. Mixed content (text next to tags), elements with xml:space="preserve", CDATA, comments and attribute values are kept exactly. If a space between two tags matters, as in <b>bold</b> <i>italic</i>, put it inside the text or use xml:space="preserve".
Can I format SVG, RSS, Android or Maven files?
Yes. They're all XML: SVG images, RSS and Atom feeds, Android layouts, pom.xml, .csproj, plist and config files.
How are attributes shown in JSON?
As keys starting with @, like "@id": "bk101". Text next to child elements goes in #text.