Data
XML to JSON Converter
Convert XML into JSON: attributes become @ keys and repeated child elements become arrays.
Written by Jay Sudha · Published · Last updated
Press ⌘ Enter to run
5 lines · 194 chars
Ready; press Run or ⌘ Enter
How this tool handles files
- Processing
- In your browser, on-device
- Storage
- Nothing stored
- Output
- A file you download
- Your responsibility
- Review before official use
- Runs in your browser. Your file is processed on your own device and, on this site, is not uploaded to our servers.
- Nothing is stored. Your file and its output are gone the moment you close or reload the page.
- Review sensitive files (bank, ID, medical) and check the output before sharing it.
Every tool on FormatOS runs in your browser. Read our Privacy Policy and File Handling Policy.
Common uses
- Modernise XML payloads for JSON APIs
- Inspect XML in a developer-friendly format
Limitations
- All values stay text; numbers and booleans are not converted
Turning XML payloads into JSON your code can use
This tool reads an XML document and rebuilds it as JSON with the same structure. The root element becomes the top-level key, nested elements become properties, and the text inside a leaf element becomes that property's value. It is built for moving data out of older XML feeds and into the JSON shape that APIs, JavaScript front ends and document stores expect.
The output is indented with two spaces, so it stays readable in a code review or a ticket. Use Download to save it as a .json file, or Copy to drop it into your editor.
How elements, attributes and text map
When a parent contains several children with the same tag, they are gathered into a JSON array, so a list of <row> elements becomes an array of row objects. A single element becomes a plain object or string instead of a one-item array, which is worth remembering if a real list sometimes has only one entry.
Attributes are kept as keys starting with @: <item id="42"> gives "@id": "42". An element that has attributes or child elements and also some text keeps that text under "#text". Comments and processing instructions are left out, since JSON has no place for them.
Values are strings exactly as written in the XML: <count>128</count> gives "128", and an empty element gives "". Convert types in your own code when your schema needs numbers or booleans.
Strict parsing, reported errors
Conversion happens entirely in your browser, and on this site your input is not uploaded to a server, which makes the tool suitable for payloads you would rather not paste into a remote service.
The parser expects well-formed XML. An unclosed tag, a bare &, mismatched nesting or a second root element stops the run with the line and column of the problem. Only XML's five predefined entities and numeric character references are understood, so an HTML name such as is reported rather than silently changed.
Checking the JSON
Check that lists you expected are arrays and that single items you expected as lists are handled by your code. Confirm that attributes you rely on appear as @ keys.
For anything official or financial, compare key values against the XML before relying on the JSON.
Frequently asked questions
Repeated child elements with the same tag are collected into a JSON array, so lists survive the conversion. A single element stays a plain value, so code that expects an array should allow for one item.
Yes. Each attribute becomes a key starting with @, such as "@id": "42". When an element has attributes and text, the text is kept under "#text".
No. The conversion runs in your browser; your text or file is processed on your own device and, on this site, is not uploaded to a server, and we do not intentionally store it.
Related data tools
Tool last reviewed: September 27, 2026 · Report a problem