Like ToolFern? Prefer us as your source on Google →

XML Formatter & Minifier

Beautify, validate, minify and convert XML to JSON instantly, with clear error messages. Perfect for tidying up config files, feeds and API payloads.

What it does

How to use it

Paste your XML into the input box and click Beautify to pretty-print it, Minify to compress it onto a single line, or To JSON to convert it. The result appears in the output box below, ready to Copy. If anything is wrong with your markup, a missing closing tag, a stray &, or mismatched elements, a clear error message tells you what the parser found. Your XML declaration (the <?xml .. ?> line) is preserved when you beautify.

XML to JSON, the exact conversion rules

The converter uses one consistent, documented convention so the output is predictable:

For example, <note id="1"><to>Tove</to><to>Jani</to></note> becomes:

{
  "note": {
    "@attributes": { "id": "1" },
    "to": ["Tove", "Jani"]
  }
}

Why an in-browser XML formatter?

XML is everywhere, RSS and Atom feeds, SVG, SOAP and other API payloads, Android and .NET config files, sitemaps and build files. This tool uses your browser's native DOMParser to parse and re-serialize the document locally. There is nothing to sign up for, no file size cap, and no waiting on a network round-trip.

Frequently asked questions

Will it tell me what is wrong?

Yes, XML that is not well-formed shows the browser parser's error message so you can fix it, in every mode, including To JSON.

Does it handle comments and CDATA?

When you beautify, comments and CDATA sections are preserved. When you convert to JSON, CDATA text is included like ordinary text, but comments are dropped, since JSON has no comment concept.

What does the "@attributes" key mean in the JSON output?

It is where the converter puts an element's XML attributes. For example, <item id="1"> becomes {"@attributes":{"id":"1"}} in the "item" key. See the conversion rules above for the full convention.

Does it validate the XML?

Yes. If the XML is not well-formed, the parser error is shown so you can fix it. If it is valid, it is beautified, minified, or converted to JSON.

What does Minify do?

Minify removes the whitespace between tags to make the XML as small as possible, which is handy for transport or storage.

How does the XML to JSON conversion work?

Elements become object keys, attributes are collected under an "@attributes" key, repeated sibling elements become arrays, and text content becomes a "#text" key, or a plain string when the element has no attributes or child elements.

Related: JSON Formatter · HTML Entity Encode / Decode

Found this useful? Share it