๐ Runs in your browser โ nothing is uploadedโ Free, no signup
XML to JSON Converter
Convert XML into clean JSON. Attributes, text content and repeated elements are kept, and numbers and booleans can be converted to real JSON types.
0 characters
JSON
When should you use the XML to JSON Converter?
- Working with an XML or SOAP API from JavaScript
- Converting an RSS feed or XML export into JSON
- Migrating XML config files to JSON
How to use the XML to JSON Converter
- 1
Paste XML
Paste your XML into the left editor, or click Load sample.
- 2
Choose how attributes look
Attributes become keys with a prefix such as @_id, so they don't clash with child elements.
- 3
Set value types
Keep 'Convert numbers & booleans' on to turn 42 and true into real JSON types.
- 4
Copy or download
Copy the JSON or download it as a .json file.
Examples
Attributes and repeated elements
XML
<book id="1"> <title>XML Guide</title> <tag>xml</tag> <tag>json</tag> </book>
JSON
{
"book": {
"title": "XML Guide",
"tag": ["xml", "json"],
"@_id": 1
}
}Common errors and how to fix them
A single item isn't an array- XML doesn't say whether an element can repeat, so one <tag> becomes a value and two or more become an array. Check for both cases in your code.
Leading zeros disappeared- Values like 007 were converted to numbers. Untick 'Convert numbers & booleans' to keep every value as text.
More from JSON Tools
Free tools that run in your browser โ no signup, nothing uploaded.
JSON Auto-Fixer & Formatter
Repair, validate, and beautify broken JSON (missing quotes, trailing commas).
JSON Validator & Linter
Check JSON syntax and see the exact line and column of every error.
JSON Viewer (Tree)
Explore JSON as a collapsible tree with search and click-to-copy paths.
JSON Editor
Edit JSON with live validation, a tree view, formatting and key sorting.
JSON Beautifier
Pretty-print and indent JSON for easy reading and debugging.
JSON Compare & Diff Tool
Find the difference between two JSON objects visually and quickly.
JSON Sorter (Sort Keys)
Sort JSON object keys alphabetically, including nested objects.
JSONPath Tester
Evaluate JSONPath expressions with filters and recursive queries.
JSON Schema Generator
Generate a JSON Schema from any sample JSON document.
XML to JSON Converter FAQ
Each attribute becomes a key with a prefix โ @_ by default โ next to the element's children, so <book id="1"> becomes "@_id": 1. You can change or remove the prefix.
Repeated elements with the same name become a JSON array. An element that appears only once stays a single value.
When an element has both attributes and text, the text is stored under #text, for example <price currency="USD">9.99</price> becomes { "#text": 9.99, "@_currency": "USD" }.
Yes โ they're XML, so any well-formed SOAP envelope or RSS feed converts. Namespaced tags keep their prefix, like soap:Body.
Yes. If the XML isn't well-formed you'll get the line and column of the error instead of a partial result.
No. Conversion happens in your browser.
