Answer: Paste XML and get properly structured, formatted JSON converted instantly, with attribute and namespace handling.
Convert XML to JSON and back — two-way, byte-exact round trips, no upload
_attributes, text under _text, repeated elements become arrays. Flip the toggle and the same engine converts JSON back to XML. It's powered by xml-js 1.6.11 (36 KB, runs in this tab) — a 254-byte catalog XML comes out as 710 bytes of pretty JSON and converts back byte-for-byte.
| XML construct | Example | JSON (compact mode) |
|---|---|---|
| Element | <book>…</book> | "book": { … } |
| Attribute | <book id="bk101"> | "_attributes": {"id": "bk101"} |
| Text content | <price>44.95</price> | "price": {"_text": "44.95"} |
| Repeated elements | two <book> siblings | "book": [{…},{…}] (array) |
| Declaration | <?xml version="1.0"?> | "_declaration": {…} |
| Comment | <!-- note --> | "_comment": "note" |
| CDATA | <![CDATA[raw]]> | "_cdata": "raw" |
| Processing instruction | <?php echo 1;?> | "_instruction": {…} |
Verbose mode keeps the document as an elements tree with type, name, and attributes fields on every node — closer to the DOM, handier for walking, heavier to read. Compact mode is what most APIs and fixtures want. The underscore prefix on reserved keys is configurable if your downstream schema forbids it.
The page runs xml-js 1.6.11 (MIT), the same engine widely used for config and fixture conversion, bundled to 36 KB with its sax parser and loaded from this site. Parsing happens in your tab: XML goes in through xml2js, JSON comes out through serialization; the reverse direction parses JSON first and rebuilds markup with json2xml. Both directions run on every keystroke, and errors surface as messages instead of silent empty output.
Take a 254-byte catalog with two books, each carrying an id attribute, an author, a title, and a priced element with a unit attribute:
That round-trip property is why this pairing is safe for round-tripping fixture data: convert, store as JSON, regenerate the XML when a legacy consumer needs it. It's also the honest answer on size — JSON repeats key names and wraps attributes and text, so element-heavy XML roughly triples in bytes going to pretty JSON. Attribute-heavy XML shrinks instead.
ns:tag becomes the key "ns:tag") — readable, but not split into namespace + local name.< in XML unescapes into JSON strings, and re-escapes on the way back.<book> is an object, two are an array. If your consumer needs stability, normalize arrays downstream.nativeType option exists for the brave.Conversion by xml-js 1.6.11 (MIT) with the sax 1.6.1 parser (BlueOak-1.0.0), bundled under /vendor/ with license texts. Nothing executes outside your browser tab.
Paste your XML and the converter parses it into a DOM tree, then walks elements, attributes, and text nodes to build the equivalent JSON, all locally in your browser. Attribute names are typically prefixed (commonly with @) to keep them distinct from child elements. Malformed XML is rejected with a parser error before any output is produced.
Mixed content — elements interleaved with free text — maps awkwardly because JSON has no way to express 'text between children' naturally. Also lost are the distinction between attributes and elements, comment nodes, processing instructions, and sibling-element order guarantees in some converters. Purely data-style XML round-trips cleanly; document-style XML does not.
Yes, this is a two-way converter, so you can round-trip in either direction. Expect cosmetic differences on the way back, such as attribute prefixing and whitespace, even when the data itself survives. Two-way conversion is handy for inspecting SOAP or config payloads in whichever format you find easier to read.