Advertisement
Guide
About the XML Formatter & Converter
XML arrives from SOAP responses, RSS feeds, sitemaps, Maven files and Android layouts — and it usually arrives as one unbroken line. This tool reformats it into something readable, minifies it when you need it small, tells you exactly where it breaks when it is malformed, and converts it to and from JSON.
Everything happens in your browser, so configuration files and API responses never leave your machine.
Formatting and validation together
There is no separate "validate" button because formatting is validation: if the document parses, you get formatted output, and if it does not, you get the reason with a line and column. Unclosed tags, mismatched closing tags, unquoted attribute values and unterminated comments are all reported where they occur rather than as a generic parse failure.
How XML becomes JSON
The two formats do not map onto each other cleanly, so this tool uses the usual conventions: attributes are prefixed with @, mixed text content becomes #text, and repeated sibling elements collapse into an array. That last part is what makes the output actually usable — without it, three <book> elements would overwrite each other and you would be left with one.
Where the conversion loses information
XML carries things JSON has no place for: comments, processing instructions, namespace declarations as distinct from ordinary attributes, and the order of elements of different names. Converting to JSON drops those. The round trip is therefore lossy by nature — fine for reading data out of a feed, not something to build a document pipeline on.
Entities and CDATA
Five characters must be escaped in XML text: &, <, >, " and '. Entities are decoded when the document is parsed and re-escaped once on output, so & stays & rather than growing an extra layer each time you format. CDATA sections are passed through untouched, which is the whole point of them.
Minifying XML
Minifying strips indentation and comments. It helps a little over the wire, but far less than gzip or Brotli, which your server almost certainly already applies — the two together is the right answer, and minification alone is rarely worth doing to a config file you still need to read.
How to use it
- 1Paste your XML into the input, or load the sample to see the format.
- 2Pick Format, Minify, or a conversion direction.
- 3If the document is malformed, the error names the line and column.
- 4Copy or download the result.
Frequently asked questions
Why does my XML fail to parse?
The most common causes are an unclosed tag, a closing tag that does not match the one that was opened, an unquoted attribute value, or a stray & that should be &. The error message gives the line and column.
How are attributes represented in the JSON output?
They are prefixed with @ — so <book id="1"> becomes { "@id": "1" }. Text content alongside attributes appears under the #text key.
Can I convert JSON back to XML?
Yes. Use the JSON → XML mode. Keys beginning with @ become attributes and arrays become repeated elements, which mirrors the forward conversion.
Is the XML to JSON conversion lossless?
No. Comments, processing instructions and the relative order of differently named elements are not representable in the JSON form, so they are dropped.
Is my XML uploaded anywhere?
No. The parser runs in your browser and nothing is sent to a server.
