Data
XML to JSON Converter
Convert XML into JSON. Repeated child elements automatically become arrays.
Press ⌘ Enter to run
5 lines · 194 chars
Ready — press Run or ⌘ Enter
Common uses
- Modernise XML payloads for JSON APIs
- Inspect XML in a developer-friendly format
Limitations
- Attributes are not preserved on every node
Turning XML payloads into JSON your code can use
This tool reads an XML document and rebuilds it as JSON, keeping the structure intact. The root element becomes the top-level key, every nested element turns into a property, and the text inside a leaf element becomes that property's string value. It is built for the everyday job of moving data out of older XML feeds and into the JSON shape that modern APIs, JavaScript front ends, and document stores expect.
Typical moments to reach for it: you receive an XML response from a legacy SOAP or RSS-style endpoint and want to inspect it as JSON, or you are migrating a configuration or data payload toward a JSON-first service. Paste the XML, press Run (or Cmd/Ctrl+Enter), and you get pretty-printed JSON you can read, copy, or hand straight to a parser.
The output is indented with two spaces, so it stays readable for eyeballing a payload and for pasting into a code review or a ticket. Use Download to save it as a .json file, or Copy to drop it into your editor.
How repeated elements and empty tags are handled
The most useful rule to understand is array collapsing. When a parent contains several child elements that share the same tag name, those repeated children are gathered into a JSON array automatically. A list of <row> elements under one parent becomes a JSON array of row objects, which is usually exactly what you want when feeding the data into a loop.
A single, non-repeated element instead becomes a plain object or string rather than a one-item array. This is worth remembering: if a real list happens to contain only one entry, that entry will not be wrapped in an array, so downstream code that always expects an array should account for the single-element case.
Leaf elements resolve to their text content as a string. Empty elements come through as an empty string rather than null, and numbers like <count>128</count> stay as the string "128" rather than a JSON number, so cast or parse values yourself when your schema needs real numbers or booleans.
Browser-only processing, valid XML, and the attribute caveat
Conversion happens entirely in your browser using the built-in XML parser. Your input is never uploaded to a server, which makes the tool suitable for inspecting payloads you would rather not paste into a remote service. Nothing leaves the page, and closing the tab clears the data.
The parser expects well-formed XML, so a single unclosed tag, a stray ampersand, or mismatched nesting will stop the run with an Invalid XML message instead of guessing. If you hit that, check that every tag is closed and that special characters are escaped, then run again. Reset sample restores the built-in example if you want a known-good starting point.
One real limitation to plan around: attributes are not reliably carried into the JSON. The converter walks child elements and text content, so values stored as attributes (for example id="42" on a tag) may be dropped. If your source keeps important data in attributes, rework the XML to express those values as child elements before converting.