XML to JSON Converter

Convert XML documents into clean, structured JSON. Preserves element hierarchy, attributes, and text content — ready for modern APIs and applications.

🔒 Runs entirely in your browser — your data never leaves this device. How we verify this.

How to Convert XML to JSON

  1. Paste your XML into the input field. The tool comes pre-loaded with sample XML — a users collection with attributes and nested elements — so you can test the conversion immediately.
  2. Choose your indentation preference. Check "Pretty-print output" for human-readable JSON with line breaks and indentation. Toggle the @ attribute prefix to clearly distinguish between XML attributes and child elements in the resulting JSON.
  3. Click "Convert to JSON". The browser's native DOMParser reads your XML, then the converter recursively walks the document tree, building a JSON object that preserves the original structure, attributes, and text content.
  4. Copy or download the resulting JSON for your application, API integration, or data analysis pipeline.

Supported XML Features

When to Use XML to JSON

Format Gotchas

FAQ

Is my data secure?

Yes. All XML parsing and JSON generation runs entirely in your browser. No data is uploaded to any server, transmitted over the network, or stored anywhere. Open your browser's Developer Tools (F12), go to the Network tab, and click Convert — you'll see exactly zero outbound requests.

What's the maximum XML file size?

The browser's DOMParser handles files up to approximately 10-50 MB depending on your device's available memory and the XML's structural complexity. Deeply nested documents with hundreds of thousands of elements consume more memory than flat ones of the same byte size. If your file exceeds this range, consider splitting it into smaller chunks or using a dedicated XML streaming parser offline.

Can I convert JSON back to XML?

Yes — our JSON to XML converter handles the reverse direction. Note that the round-trip is not always lossless: XML attributes (converted with the @ prefix) may not map back identically, and mixed content sequences cannot be reconstructed exactly.

Are XML attributes preserved in the output?

Yes. By default, attribute names are included as-is. Enable the "Prefix attributes with @" checkbox to visually distinguish them — <book genre="fiction"> becomes "@genre": "fiction". Without the prefix, the attribute key is just "genre" with no visual distinction from child elements.

How does the converter handle XML namespaces?

Namespace prefixes are preserved in the tag name as JSON keys. <dc:title> becomes the key "dc:title". The namespace URI itself is not resolved or included separately. If you rely on namespace resolution, you'll need to post-process the JSON to map prefixes to their full URIs.