Code Beautifier

XML to JSON

Convert XML documents into readable, valid JSON objects with automatic type parsing and attribute preservation. · Updated

Options
Indent size:
Attribute prefix:
xml
json
Draft saved locally.

Options

OptionDescription
Indent sizeNumber of spaces per nesting level (0 for minified JSON).
Ignore XML attributesWhen checked, XML tag attributes (like id='123') are omitted from the JSON output.
Auto-parse numbers & booleansAutomatically converts numeric strings (e.g. '44.95') to numbers and 'true'/'false' to booleans.
Attribute prefixPrefix applied to attribute keys in the resulting JSON object.

FAQ

How does XML to JSON handle XML attributes?

Attributes are preserved as object properties with a configurable prefix (e.g. @_id). You can also choose to ignore attributes entirely.

Does this tool validate XML syntax?

Yes. The parser checks for well-formed XML and reports exact line and column numbers if syntax errors or unclosed tags are detected.

Can I convert XML to minified JSON?

Yes. Set 'Indent size' to 0 in the options panel to produce single-line compact JSON.

How are repeated child tags converted?

Multiple XML elements with the same tag name are automatically aggregated into a JSON array.