Skip to content

← All tools

XML Formatter & Converter

Format, validate and minify XML with the browser’s strict parser — real errors instead of silent fixes — and convert between XML and JSON using the standard attribute/text mapping. Everything runs locally in your browser.

New to this? Read the XML Formatter & Converter guide →

Mode

Validation and formatting

Your XML is parsed with the browser's own strict XML parser, so anything malformed — an unclosed tag, a stray &, mismatched nesting — is rejected with the parser's error message rather than silently "fixed" the way HTML parsers do. Well-formed input is re-indented cleanly (elements with only text stay on one line; empty elements collapse to <tag/>), and comments, CDATA sections and the XML declaration are preserved.

How the JSON conversion maps

XML and JSON don't share a data model, so the mapping follows the common convention: attributes become "@name" keys, element text becomes a plain string (or "#text" when the element also has attributes or children), and repeated sibling elements become arrays. The same convention runs in reverse for JSON → XML, so simple documents round-trip. Namespaces are carried as-is in element names. The guide explains the mapping's inherent edges — most importantly that a single child can't be told apart from a one-item list without a schema.

Frequently asked questions

Why does the formatter reject XML my browser displays fine?

Browsers repair broken HTML, but XML is strict by design: every tag must close, attributes must be quoted, and & must be written &amp;. The tool uses the browser’s strict XML parser so you get the real error and line instead of a silently “fixed” document — the unescaped ampersand in a URL is the most common culprit.

How are attributes and repeated elements converted to JSON?

Using the standard convention: attributes become "@name" keys, element text becomes a string (or "#text" when the element also carries attributes or children), and repeated sibling elements become arrays. The same mapping runs in reverse for JSON → XML, so simple documents round-trip.

Why did my single <item> convert to an object instead of an array?

Because XML cannot express “a list with one item” — one child element is indistinguishable from a single value without a schema. Code consuming converted JSON should tolerate both shapes; it is the classic edge case of XML→JSON pipelines.

Is my XML uploaded?

No. Parsing, formatting and conversion all run locally in your browser using its built-in XML parser.

Related tools