XML to JSON Converter Online Free
Paste any XML and get clean, valid JSON instantly. Handles attributes, namespaces, arrays, nested elements, and CDATA. Everything runs in your browser. No data sent anywhere.
XML parsed by the browser’s own DOMParser, then walked into JSON by hand
Rather than writing a custom XML tokenizer, this tool hands your input to DOMParser, the same engine the browser uses to parse XML documents and SVG. That means malformed XML is rejected with the browser’s own real parser error, not a guess from a regex. Once parsed into a DOM tree, the tool walks it recursively and builds a plain JavaScript object, which is then serialized to JSON. Everything happens locally; there is no server call anywhere in the conversion path.
The tree-walking algorithm
new DOMParser().parseFromString(xml, 'text/xml') builds the tree. Browsers report a parse failure by inserting a <parsererror> element into the resulting document rather than throwing, so the tool explicitly checks for that node and throws its own error using the browser’s message.
{ "_cdata": "..." } to mark it as having come from a CDATA block. Comment nodes (type 8) are dropped entirely.
@ (the default, avoiding collisions with child element names), merged directly as sibling keys, or dropped entirely, depending on the attribute mode setting.
<item> elements becomes a JSON array automatically.
Conversion options and what each one changes
| Option | Effect |
|---|---|
| Attribute mode | Prefix with @, merge as plain sibling keys, or ignore attributes entirely. |
| Text key | The property name used for an element’s own text content when it also has attributes or children (defaults to _text), since a plain string value would otherwise be ambiguous with a child element of the same name. |
| Parse numbers | Text content that passes !isNaN(Number(trimmed)) is converted from a string to an actual JSON number. |
| Parse booleans | Text content matching the literal strings true or false becomes a real JSON boolean. |
| Force arrays | Every child element becomes a single-item array on first occurrence too, useful when downstream code expects a consistent array shape regardless of how many times a tag repeats. |
| Strip namespaces | Removes everything before and including a colon in a tag or attribute name, so soap:Envelope becomes Envelope. |
null for it rather than an empty object. This matches common XML-to-JSON library conventions but is worth knowing if your downstream code expects an empty object {} instead, since null and {} behave very differently once you start accessing properties on them.The reverse direction and other views
JSON back to XML
The swap button reverses the process with its own recursive serializer: keys starting with @ become attributes again, arrays become repeated sibling tags, and the configured text key becomes the element’s text node.
Interactive tree view
A collapsible JSON tree is built as real DOM nodes (not just text), letting you fold and unfold nested objects and arrays to explore deeply nested XML without scrolling through raw text.
Structural stats
Element count, attribute count, and maximum nesting depth are computed by walking the original XML DOM tree, separate from the JSON stats shown for the converted output.
Parsing standards and tools
- MDN: DOMParser documents the browser API this tool relies on for parsing and error detection.
- W3C Extensible Markup Language (XML) 1.0 specification is the formal grammar the browser’s parser implements.
- fast-xml-parser is a widely used Node.js alternative with similar attribute-prefixing and array-forcing conventions, useful for server-side conversion at scale.
- W3C Namespaces in XML 1.0 covers the colon-prefixed namespace syntax the strip-namespace option removes.
Legacy data jobs
Converting a SOAP or legacy XML API response into JSON for use in a modern JavaScript frontend, inspecting an RSS or Atom feed’s structure before writing a parser against it, migrating configuration files from XML to JSON, checking how deeply nested a third party XML export actually is before writing processing code, and turning a downloaded XML sitemap or data export into something easier to query with standard JSON tools.
FAQ: XML to JSON Converter Online Free
Yes, completely free. No account, no signup, no payment required. The tool will stay free forever.
No. All conversion happens inside your browser using JavaScript. Nothing is transmitted to any server. You can safely use it with sensitive or proprietary XML.
You choose. The @prefix option adds an @ before each attribute name so it is easy to distinguish from child elements. The Merge option puts attributes at the same level as children. The Ignore option drops all attributes entirely. Pick whichever matches your downstream usage.
Repeated sibling elements with the same tag name are automatically grouped into a JSON array. So three item tags under a list element become an array of three objects. You can also enable Force arrays to always produce arrays even when there is only one child.
Yes. Click the Swap button to switch the tool into JSON to XML mode. Paste your JSON into the input, click Convert to XML, and download the result as a .xml file.
Yes. By default, namespace prefixes like soap:Body appear as-is in the JSON keys. Enable the Strip namespaces option to remove all prefixes and get cleaner key names. This is useful when working with SOAP APIs or WSDL-based services.
CDATA sections in XML let you include characters like angle brackets without escaping them. With Preserve CDATA enabled, the tool wraps CDATA content in a _cdata key so you know it was a CDATA section. Disable the option to collapse CDATA content directly into a plain string value.
Yes. Click Upload .xml to pick a file from your device, or drag and drop any .xml file directly onto the input area. The file is read locally and never uploaded to a server.
Yes, by default. Text like “42” becomes the JSON number 42, and “true” becomes the JSON boolean true. You can disable either option separately if you need values to stay as strings.
There is no enforced limit. Very large XML files may take a moment to process depending on your browser and device. For files above a few megabytes, the conversion still works but may be slightly slower on older hardware.
From the blog
Deep dives on the things these tools touch
Minification, UUID collisions, diffing API responses, and the other questions that come up around this toolset.