XML to JSON Converter

Convert XML documents to JSON format instantly in your browser. Handles nested elements, attributes, arrays, and CDATA sections.

0 chars
Conversion Rules
XML elementJSON object key
XML attribute@attributeName key
Text-only elementString / number / boolean value
Repeated elementsJSON array
Mixed content (text + children)#text key for text
CDATAPlain string value

What is XML to JSON Converter?

This tool converts XML documents to JSON format entirely in your browser. Paste any valid XML and click Convert — it handles nested elements, attributes, repeated elements (arrays), CDATA sections, and mixed content.

How to Use

  1. Paste your XML into the input panel on the left (or click "Load Example" to try a sample)
  2. Click "Convert to JSON" to parse and transform the XML
  3. Review the JSON output in the right panel
  4. Click "Copy" to copy to clipboard, or "Download" to save as a .json file
  5. If there is a parse error, the tool shows exactly which part of the XML is invalid

Why Use This Tool?

Runs entirely in your browser — no data is sent to a server
Handles attributes (converted to @attr keys), arrays, and CDATA automatically
Supports nested elements of any depth
Auto-detects numbers and booleans — no string wrapping of numeric values
Download output as a .json file with one click
Handles XML namespaces and processing instructions gracefully

Tips & Best Practices

  • XML attributes become @attributeName in JSON (e.g., id="1" → "@id": "1")
  • Repeated sibling elements with the same tag become a JSON array automatically
  • Text-only elements become simple string/number/boolean values, not objects
  • CDATA sections are treated as plain text — the CDATA wrapper is stripped
  • The XML declaration (<?xml version="1.0"?>) is ignored and does not appear in output
  • For large files, copy-paste works fine — the browser DOM parser handles files up to hundreds of MB

Related Tools