XML to JSON Converter
Convert XML to JSON without losing attributes or text nodes
What is XML to JSON Converter?
This XML to JSON converter maps tag structure onto JSON objects: attributes are preserved under an @ prefix, the text of mixed content goes into #text, and sibling elements sharing a name are merged into an array. Parsing uses the built-in browser DOMParser and happens entirely on your own machine.
How to use XML to JSON Converter
- 1Paste your XML document or SOAP envelope.
- 2Read the output: attributes appear as @name, text as #text, and repeated tags as arrays.
- 3Switch to "Minify" to collapse the result onto a single line.
Frequently asked questions
Why are attributes given an @ prefix?+
In XML an attribute and a child element are allowed to share the same name, so expanding both straight into object keys would let one silently overwrite the other. The @ prefix is the established convention, used by BadgerFish and similar specifications, and it keeps the conversion lossless and reversible.
Why is a single child element not wrapped in an array?+
XML itself draws no distinction between one element and a list that happens to contain one element, so the converter has nothing to go on. If your downstream code expects an array, normalize the shape in your own code or switch to a schema-aware converter.
Related tools
All toolsJSON to YAML Converter
Convert JSON to YAML while preserving the nesting
YAML to JSON Converter
Convert YAML to JSON, multi-document files included
JSON to CSV Converter
Convert a JSON array of objects to CSV, with nested fields flattened automatically
CSV to JSON Converter
Convert CSV to JSON with automatic header and delimiter handling
JSON to TypeScript
Infer TypeScript type definitions from JSON
JSON to Go Struct
Convert JSON to Go structs with json tags filled in