XML ⇄ JSON Converter
Turn XML into JSON and back without uploading anything. XML to JSON produces a predictable structure: attributes become @-prefixed keys, repeated sibling elements become arrays, text content becomes #text when an element also has attributes or children, and comments/processing instructions are skipped. JSON to XML turns those same conventions back into well-formed, indented XML with proper escaping. Entity references, CDATA sections, self-closing tags and namespaces are supported.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
Two directions, one set of conventions
XML to JSON reads a document and returns an object whose single key is the root element name, with the element’s contents nested beneath it; the download is named after that root, for example catalog.json. JSON to XML goes the other way and insists on a single root key — that key becomes the root element and the object inside it becomes its contents — then prepends an XML declaration and writes a file named after the root. The pairing means a document can be round-tripped through JSON and back.
Where attributes and text end up
Attributes have three treatments. The default prefix mode gives each one an at-prefixed sibling key, so id="1" becomes "@id": "1". The nest mode collects them into a single @attributes object, which keeps element names uncluttered. The ignore mode drops them entirely when you only care about content. Text content goes under the configured text key, #text unless you rename it, and only when the element also carries attributes or children — a plain element with only text becomes a simple string value.
Repeated elements and JSON shapes
XML happily repeats a sibling element, but a JSON object cannot hold two keys with the same name, so the reader collects repeats into an array and leaves a single occurrence as a plain value. Writing back applies the same rule in reverse: a JSON array becomes the element repeated once per item, an empty array or null becomes a self-closing tag, and a non-object value becomes the element’s text. Attribute keys may also be written as @name or inside an @attributes object; either is accepted.
What is lost, what is not, and privacy
Comments, processing instructions and DOCTYPE declarations are skipped on the way in, so they do not survive a round trip. Values are deliberately left as strings rather than coerced to numbers or booleans, which keeps the conversion lossless; numeric types only appear when you convert real JSON numbers back to XML. Indentation is clamped between 0 and 8 spaces, and attribute names that are not valid XML names are rejected with an error rather than emitted broken. Parsing and serialisation run entirely in the tab — your XML is never uploaded.
Questions
Is my XML uploaded?
No. Parsing and serialization run entirely inside your browser tab.
Why do repeated elements become arrays?
JSON objects cannot hold duplicate keys, so sibling elements sharing a name are collected into an array — a single occurrence stays a plain object or string.
Do comments survive a round trip?
No. Comments, processing instructions and DOCTYPE declarations are ignored; element data, attributes, text and CDATA content are preserved.
Are values converted to numbers or booleans?
Not by default — everything is kept as a string so the conversion is lossless. Numbers are only emitted when you convert a JSON document containing real numbers back to XML.
Related tools
See categoryXML Formatter
Pretty-print or minify XML with a pure-JS tokenizer — comments, CDATA and PIs kept intact.
JSON to YAML
Convert JSON to YAML on your device, with a 2- or 4-space indent.
YAML to JSON
Convert YAML to JSON locally, with indent choice and optional key sorting.
TOML ⇄ JSON Converter
Parse TOML into JSON, or serialize JSON back to TOML.