XML to JSON
Paste XML and get JSON instantly, with attributes kept or ignored, indent control, and errors that point at the line.
Converted live as you type. Nothing leaves your browser.
Attributes
Indentation
JSON
How to convert XML to JSON online
Paste your XML
Drop an XML document into the input. The JSON appears live as you type, and invalid XML shows the error with the line where it occurs.
Choose attributes and indentation
Keep attributes as prefixed keys or ignore them, and pick 2 spaces, 4 spaces, or minified output. The JSON regenerates the moment you switch.
Copy the JSON
Click Copy JSON to take the result to your editor, terminal, or API client.
Why use this tool
You decide what happens to attributes
Keep them as keys with an @ prefix so they never collide with child elements, or ignore them for a cleaner result. Switching re-converts instantly.
Errors with line numbers
Invalid XML shows the validation error together with the line where it occurs, and clears as soon as the input is valid again.
Repeated elements become arrays
One element converts to an object or value; several siblings with the same name convert to a JSON array, one entry per occurrence, with a note under the output saying so.
Numbers and booleans, carefully
Values that are plain numbers or the words true and false become JSON numbers and booleans. Values with leading zeros, hex notation, or exponents stay strings.
Indented or minified output
2 spaces, 4 spaces, or a single minified line with no whitespace. The output regenerates instantly when you switch.
Feeds and exports stay on your machine
The conversion runs in your browser, so responses and exports that carry order data, tokens, or internal URLs are never uploaded.
About this tool
This tool converts XML to JSON in your browser. Paste an XML document and the JSON equivalent appears as you type, indented with 2 or 4 spaces or minified to a single line. Nested elements become nested objects, repeated elements with the same name become arrays, and values that are plain numbers or the words true and false are converted to JSON numbers and booleans. Anything ambiguous, like a part number with leading zeros, stays a string.
Most XML in circulation is the older half of an integration: SOAP responses, RSS and Atom feeds, sitemaps, invoice exports, and configuration files that predate JSON APIs. The tooling around them now speaks JSON, so converting is the quickest way to inspect a response, feed a payload into a script, or see what a deeply nested document actually contains. The one decision XML forces is attributes, because JSON has no direct equivalent. Given a price element with a currency attribute, keeping attributes produces an object holding both the amount and a "@_currency" key, while ignoring them produces just the amount. The pill next to the output switches between the two instantly.
Repeated elements are folded into arrays, one entry per occurrence, and a note under the output says when that happened, so nothing is reshaped silently. Elements that mix text with attributes or children keep their text under a "#text" key. Nothing you paste leaves your browser, which matters for responses and exports that carry customer data or internal URLs. The XML formatter tidies a document before converting, the JSON formatter restyles the result afterwards, and the YAML to JSON and CSV to JSON converters do the same job for configs and tables.
Frequently asked questions
- What happens to XML attributes?
- You choose. Keep them and each attribute becomes a key prefixed with @ so it cannot collide with a child element of the same name, or ignore them and only element content is converted. The setting sits next to the output and re-converts instantly.
- Why did my repeated elements turn into an array?
- JSON cannot repeat a key inside one object. When several sibling elements share a name they are collected into an array, one entry per occurrence, and a note under the output says when that happened. A single occurrence stays a plain object or value.
- Are numbers and booleans converted?
- Only when unambiguous. Plain numeric values become JSON numbers and the exact words true and false become booleans. Values with leading zeros, hex notation, or exponent notation stay strings, so identifiers like 007 are not mangled.
- Why does my XML show an error?
- The input is validated before it is converted, and the inline error reports the line where validation failed, such as a mismatched closing tag or a stray angle bracket. It clears the moment the input becomes valid. The XML formatter can help tidy a messy document first.
- How are comments, CDATA, and the XML declaration handled?
- The XML declaration and processing instructions are dropped, comments are dropped because JSON cannot represent them, and CDATA sections are treated as ordinary text. Elements that mix text with attributes or children keep their text under a "#text" key.
- Is my XML uploaded anywhere?
- No. The conversion runs entirely in your browser. Nothing is sent to a server, stored, or logged, which matters for SOAP responses and exports that carry customer or order data.
Related tools
XML Formatter & Validator
Pretty-print, minify, and validate XML, with the parse error shown inline.
JSON Formatter & Validator
Pretty-print, minify, or explore JSON as a collapsible tree, with syntax errors shown inline.
Angle Converter
Convert an angle between degrees, radians, gradians, turns, arcminutes and arcseconds, with a degrees-minutes-seconds breakdown.
Area Converter
Convert area between metric and imperial units instantly.
Binary to Decimal Converter
Convert a binary number to its decimal value, with hexadecimal and octal readouts.
Celsius to Fahrenheit Converter
Convert Celsius to Fahrenheit instantly, and edit either side to convert back.