Skip to content

Data converter · local processing

Convert XML to an explicit JSON structure

The converter parses well-formed XML in your browser and returns a predictable tree. Attributes stay in attributes and ordered text or child elements stay in content, avoiding ambiguous shortcuts.

Input

Your data stays in this browser.

The gray text is an example. Run uses it; selecting the input clears it. Leave it empty to restore the example.

Paste one complete XML document with a single root element. · 39 / 200,000

Options

DOMParser · XML 1.0

Result

How XML becomes JSON

Convert a document

  1. Paste a complete XML document.
  2. Select Convert to JSON.
  3. Inspect name, attributes and the ordered content array.
  4. Copy the JSON and test it with the system that will consume it.

Mapping rules

Every element becomes { name, attributes, content }. Repeated children remain separate content entries and mixed text stays in its original order.

Namespace prefixes and xmlns declarations stay in tag and attribute names. The tool does not silently expand, remove or remap namespaces.

Security and fidelity limits

  • DTD and entity declarations are rejected; no external resource is requested and XML is never rendered as HTML.
  • Comments and processing instructions are omitted. Whitespace-only text between elements is omitted, while meaningful text and CDATA are preserved.

XML to JSON FAQ

Why is content an array?

An array can preserve the order of text and repeated child elements, including mixed content.

Are namespaces preserved?

Prefixes and namespace declaration attributes are preserved literally; no namespace-resolution policy is imposed.

Can it convert JSON back to XML?

No. Reverse conversion has different escaping and structure decisions and is outside this page.