XML to JSON Converter
Convert XML to JSON instantly — paste, convert, and copy your data.
Converted JSON will appear here...About XML to JSON Converter
XML to JSON Converter translates the tree structure of an XML document into an equivalent JSON object, preserving every attribute, child element, and text node. The root element becomes the top-level key, child elements become nested objects, and any XML attributes appear as properties prefixed with @_ so they cannot be confused with child elements. When the same tag name appears more than once inside a parent, the tool automatically promotes those entries to a JSON array — no manual cleanup required.
The converter is built for integration work: consuming a SOAP or RSS feed in a JavaScript application that expects JSON, preparing XML configuration exports for a NoSQL import, or inspecting the structure of a legacy enterprise payload before writing a mapping layer. Unlike a JSON formatter (which only re-indents existing JSON) or an XML formatter (which only pretty-prints XML), this tool actually changes the data format — the output is valid JSON that any JSON parser can read.
Every conversion runs entirely inside your browser via the native DOMParser API. Your XML is never uploaded, logged, or transmitted to any server, so internal configuration files, API responses with credentials, and proprietary data schemas stay completely private on your own machine. There are no file-size limits, no accounts, and no cost.
Key Features
Attribute-aware mapping
XML attributes are preserved as @_-prefixed keys in the JSON output, keeping them distinct from child element keys and making the mapping unambiguous.
Automatic array promotion
When the same element tag appears more than once under a parent, the tool groups those entries into a JSON array automatically — no manual post-processing needed.
CDATA and mixed-content support
CDATA sections are captured under a #cdata key and text nodes alongside child elements are stored as #text, so no content from the original XML is silently dropped.
Configurable indentation
Choose 2, 4, 6, or 8 spaces for the JSON output, or switch to compact (minified) mode when you need a single-line payload for an API request or a storage field.
100% client-side — no uploads
Conversion runs in the browser using the native DOMParser. Your XML never leaves your device, making it safe for credentials, internal schemas, and proprietary configuration files.
Instant error reporting
If the XML is malformed, the parser surfaces the exact error message rather than producing silently broken JSON, so you can fix the source document before using the output.
How to Use
Paste XML
Copy your XML code and paste it into the left input pane.
Convert
Click "Convert" to transform your XML into a JSON object.
Copy Result
Use the copy button to grab your JSON output.
Example
A product catalog entry with attributes and repeated child elements. Attributes become @_-prefixed keys; the two tag elements are automatically grouped into a JSON array.
<product id="P42" currency="USD">
<name>Wireless Headphones</name>
<price>89.99</price>
<tag>audio</tag>
<tag>wireless</tag>
</product> {
"product": {
"@_id": "P42",
"@_currency": "USD",
"name": "Wireless Headphones",
"price": "89.99",
"tag": [
"audio",
"wireless"
]
}
} Common Use Cases
- arrow_circle_right
Consuming SOAP or RSS feeds in a JS app
Many enterprise APIs and feed formats still return XML. Convert the response to JSON once so your JavaScript code can use standard dot-notation and array methods instead of DOM traversal.
- arrow_circle_right
Preparing XML exports for NoSQL ingestion
Document databases like MongoDB and Firestore expect JSON. Convert an XML data export to JSON as the first step in a migration pipeline before loading it into the database.
- arrow_circle_right
Inspecting legacy API payloads
When you receive an unfamiliar XML payload and need to understand its structure, converting it to JSON makes the hierarchy immediately readable in any JSON viewer or browser console.
- arrow_circle_right
Writing field-mapping code between formats
Before coding a transformation layer between an XML source and a JSON target, use this tool to see exactly how attributes, repeated elements, and text nodes map so you can write accurate selectors from the start.
- arrow_circle_right
Verifying XML-to-JSON library output
When evaluating a parsing library in your codebase, paste the same XML here to get a reference output and compare it with what your library produces — quickly spot attribute handling or array-promotion differences.