Developer Tools

XML to JSON Converter

Convert XML data to a JSON object instantly. Handles attributes, nested elements, and repeated tags — free, browser-based, no uploads.

No uploads — browser onlyInstant result
JSON indentspaces

XML Input

How to convert XML to JSON

  1. Paste your XML into the input area.
  2. Choose the JSON indentation level.
  3. Click Convert to JSON.
  4. Copy the JSON output or download it as a file.

Convert legacy XML into JSON

XML is still everywhere — REST and SOAP APIs, RSS feeds, configuration files, office documents, and older enterprise systems. Converting it to JSON makes the data far easier to use in modern web applications, JavaScript, and tooling, and it is a common step in data migration and system integration work. Paste your XML above to get clean, indented JSON you can copy or download.

How attributes and repeated tags are handled

XML attributes are prefixed with @ in the JSON output (e.g., "@id": "bk101"). Repeated sibling elements with the same tag are automatically grouped into JSON arrays. Text content of elements with attributes is stored as "#text".

Why XML and JSON are not perfectly equivalent

XML can express things JSON has no direct equivalent for, so a few details are handled pragmatically. Attributes are kept with an @ prefix and repeated sibling tags become arrays, but XML comments are dropped, CDATA sections are kept as plain text, and namespace prefixes are preserved literally in key names without resolving their URIs. With mixed content — text interleaved with child elements — the child elements are kept while the loose text around them is not. For most data-style XML this produces clean, predictable JSON; heavily document-style markup may need manual adjustment.

Privacy — processed in your browser

Conversion uses the browser's DOMParser to parse XML and native JSON.stringify for output. Your data never leaves your device.

Frequently Asked Questions

What happens to XML comments?

XML comments are not included in the JSON output — only elements, attributes, and text content are converted.

What happens to CDATA sections?

CDATA content is treated as the element's text value, so it appears in the JSON like any other text node.

Does it support mixed content?

Elements that mix free text with child elements keep their child elements in the JSON, but the loose text around those children is not retained. This suits data-style XML more than document-style markup.

What happens with XML namespaces?

Namespace prefixes are preserved in the tag names as-is (e.g. <ns:element> becomes "ns:element" in JSON). Full namespace URI resolution is not performed.

What if the XML is invalid?

The converter uses the browser's XML parser. If the document is not well-formed, conversion stops and an error message describing the problem is shown instead of partial output.

What if my XML has multiple root elements?

Valid XML requires exactly one root element. If your document has multiple roots it is not well-formed XML and the parser will report an error.

Can I convert an XML file?

Paste the contents of your XML file into the input box — the tool works with pasted text rather than a file upload.

Is my XML uploaded?

No. Parsing uses the browser's built-in DOMParser and runs entirely on your device. Your XML is never sent to a server.

Can I format the resulting JSON?

Yes — choose 2- or 4-space indentation above the output, or send the result to the JSON Formatter for more options.

Can I convert JSON back to XML?

Yes — use the JSON to XML tool for the reverse direction.

Does this handle large XML files?

The converter runs in the browser's main thread and is suitable for moderate-sized files. Very large files (>10 MB) may cause the browser to pause briefly.

Related tools