XML to JSON Converter

Convert XML into readable, indented JSON in your browser, using the browser's own XML parser. Attributes are dropped and repeated tags become arrays.

Document Tools Free No upload Instant

Loading XML to JSON Converter…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Paste XML and get indented JSON. The tool parses your XML with the browser's own engine and turns each element into a JSON property, using the tag name as the key. Text content becomes a string, a repeated tag becomes an array, and a tag that appears once stays an object. Attributes are not included. Everything runs in your browser.

What the XML to JSON Converter Does

This reads an XML document and produces the equivalent JSON, pretty-printed with two-space indentation. Each element becomes a key named after its tag, and the nesting follows the XML structure.

Two things are worth knowing up front. XML attributes are dropped — only element text and child elements are kept — and a tag that repeats becomes a JSON array while a tag that appears once stays a plain value, so the shape depends on how many siblings are present.

How It Works

Paste or type your XML. It is parsed by the browser's built-in DOMParser — a real XML parser, not a regular expression.

The tool walks the element tree from the root. An element with no child elements becomes its text content as a string; an element with children becomes an object keyed by the child tag names.

When the same tag appears more than once under a parent, those values are collected into an array. The result is printed as indented JSON you can copy or download.

Data source & conversion logic

  1. Parse with DOMParser. The browser's XML parser builds a document tree from your text.
  2. Walk from the root. Each element is visited starting at the document root.
  3. Map elements to keys. Leaf elements become strings, parents become objects, and repeated tags become arrays.
  4. Pretty-print JSON. The result is serialised with two-space indentation to copy or download.

How XML maps to JSON

Leaf element (text only) = a string value Element with child elements = an object keyed by child tag Same tag repeated under one parent = an array Attributes = not included
Worked example
The XML <row><name>Alice</name><age>30</age></row> inside a <rows> element becomes {"row": {"name": "Alice", "age": "30"}} — and age is text, not a number.

Because a single row is an object but two rows would become an array, the JSON shape depends on how many matching tags exist.

Privacy

Your XML is parsed and converted entirely in your browser — there is no server and nothing is uploaded.

The data never leaves your device, so even sensitive records stay private.

No account, no stored copy; the conversion is gone when you close the tab.

Technical Details

InputXML
OutputIndented JSON (.json)
ParserBrowser DOMParser
AttributesDropped
Leaf valuesAlways strings
Repeated tagsBecome arrays
Processing100% in-browser

Standards & references

  • DOMParser — The browser's standard XML parser turns the text into a document tree before conversion.
  • No universal XML-to-JSON mapping — There is no single official mapping; tools differ on attributes, arrays and mixed content. This tool keeps elements and drops attributes.
  • JSON (RFC 8259) — Output is standard JSON, pretty-printed with two-space indentation.

Accuracy & Limitations

Attributes are dropped. The walk only reads element nodes and their text, so a tag like row with an id attribute loses that id. If your data lives in attributes, this tool is not the right fit.

Leaf values are always strings. A number in the XML, such as a year of 2024, comes out as text rather than a JSON number — there is no type inference.

A tag that appears once becomes an object or string; the same tag repeated becomes an array. This single-versus-array ambiguity is inherent to XML, so the JSON shape can change with the number of records.

Mixed content — an element holding both text and child elements — keeps only the child object and drops the loose text.

Parsing uses the browser's DOMParser, which does not throw on broken XML; instead it returns a document containing a parser-error element, so malformed input can produce odd JSON rather than a clear error. Check that your XML is well-formed first.

Real-World Use Cases

Read XML in a JS app

Turn an XML API response into JSON your JavaScript can use directly.

Inspect a feed

Convert an RSS or config XML into readable JSON to see its structure.

Bridge old to new

Move data from an XML source toward a JSON-based pipeline.

Quick comparison

Flatten XML into JSON to diff it against another JSON document.

When to use it — and when not to

Good for

  • Element-centric XML where data is in tags, not attributes
  • Quick reads of an XML feed or response as JSON
  • Simple structures without mixed content

Not the best choice for

  • XML whose data is stored in attributes
  • Documents with mixed content or namespaces
  • Cases where you need numbers and booleans typed

If your XML relies on attributes, namespaces or mixed content, use a configurable XML-to-JSON library. To turn JSON back into XML, use the JSON to XML converter.

Frequently Asked Questions

Does it keep XML attributes?
No. Attributes are dropped; only element text and child elements are kept. A tag like item with a price attribute loses that price in the JSON.
Why is my number a string?
Leaf values are always strings. A value like 2024 comes out as text rather than a JSON number, because the tool does no type inference.
Why did one record become an object but many become an array?
A tag that appears once becomes an object, and the same tag repeated becomes an array. This single-versus-array ambiguity comes from XML itself, which has no syntactic difference between one element and a list.
What parser does it use?
The browser's built-in DOMParser — a genuine XML parser — so nesting, entities and CDATA are read correctly, not approximated with a regular expression.
What happens with malformed XML?
DOMParser does not throw on bad input; it returns a document containing a parser-error element. That can produce odd JSON, so make sure your XML is well-formed first.
Does it handle mixed content?
Partly. If an element holds both text and child elements, the tool keeps the child object and drops the loose text, because JSON has no natural place for both.
Does it handle namespaces?
Tag names are used as they appear, prefix included. There is no namespace resolution, so a prefixed tag keeps its prefix in the key.
Is the JSON indented?
Yes. It is pretty-printed with two-space indentation so it is easy to read and copy.
Can it convert back to XML?
Yes, with the JSON to XML converter — though attributes dropped here will not return, since they were never carried into the JSON.
Are CDATA sections handled?
Yes. The text inside a CDATA section is read as the element's text content.
Is my data uploaded?
No. The XML is parsed entirely in your browser, so nothing leaves your device.
Why don't I get the same JSON as another tool?
Because there is no universal XML-to-JSON standard. Tools differ in how they handle attributes, single-versus-array and mixed content, so results vary.

References

Parses your XML with the browser's built-in DOMParser and walks the element tree into JSON: text becomes string values, a repeated tag becomes an array, and a single tag stays an object. Attributes are not included. Runs entirely in your browser.

Popular

CSV to JSON Converter

CSV to JSON Converter online: fast, private and free for everyday document work.

DocumentOpen Tool
Popular

JSON to CSV Converter

Convert with JSON to CSV Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool
Trending

Markdown to HTML

Markdown to HTML in seconds — accurate, free and processed locally in your browser.

DocumentOpen Tool

CSV to Excel Converter

Convert with CSV to Excel Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool

Excel to CSV Converter

Excel to CSV Converter online: fast, private and free for everyday document work.

DocumentOpen Tool

Excel to JSON Converter

Convert with Excel to JSON Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool

Ready to try the XML to JSON Converter?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.