XML to JSON Converter
ConvertConvert XML documents into clean, structured JSON in one click.
Convert XML to JSON online
Modern code is far happier with JSON than XML. This converter parses an XML document and produces clean, structured JSON you can work with directly. It validates the XML first, so malformed input is reported with the exact line and column of the problem rather than producing garbage.
Attributes become @-prefixed keys, element text becomes #text, and repeated sibling elements are collected into JSON arrays — the natural JSON equivalent of an XML list.
Keep types as numbers or strings
XML has no concept of types — everything is text. Turn on type inference and numeric and boolean text becomes real JSON numbers and booleans; leave it off to keep every value as a string exactly as written. Because this tool and the JSON to XML converter share the same attribute and text conventions, you can round-trip between the two formats without losing structure.
When to turn type inference off
Type inference is convenient until a value only looks numeric. ZIP codes, phone numbers, order IDs, and version strings lose their leading zeros or trailing digits the instant they become real numbers — 01234 comes back as 1234 and 01.20 as 1.2 — and the text true or false flips into a boolean. Any field that is an identifier rather than a quantity is safer left alone.
When your XML carries codes like these, switch Infer types off so every value stays a string exactly as written, then coerce the genuinely numeric fields yourself in code. Leave it on when the document is mostly measurements, counts, and flags and you want real JSON numbers and booleans without a second pass.
Why one element becomes an object, not an array
JSON has no schema, so the converter infers a list purely from repetition. A tag that appears once under its parent becomes a single value or object; the same tag appearing two or more times becomes a JSON array. That means an <order> with one <item> and an <order> with three <item>s produce different shapes — a single value in the first case, an array in the second — even though you think of both as lists.
If your code always expects an array, plan for it: normalize after conversion by wrapping a lone value in an array, or convert a sample that already contains at least two repeated entries so the structure you code against matches what production returns. Paste the result into the JSON tree viewer to confirm exactly where objects and arrays landed before you rely on the shape.
Namespaces, comments, and the XML declaration
Not everything in an XML document is data, and the converter treats each part accordingly. Namespace prefixes are kept as part of the key, so a tag like <soap:Envelope> becomes the JSON key soap:Envelope and an xmlns declaration lands as an @-prefixed attribute — nothing about the namespace is silently discarded. The <?xml ?> declaration, processing instructions, and comments are dropped, since they carry no values you would query, and whitespace around text values is trimmed.
Because the same @-attribute and #text conventions drive both directions, you can send the output straight back through the JSON to XML converter and get a structurally equivalent document, minus the comments that were never part of the data in the first place.
Convert sensitive XML without uploading it
SOAP responses, exported configuration, and billing feeds often hold data you would rather not paste into an unknown web service. Every conversion here runs entirely in your browser — the XML never leaves your machine, there is no upload step and no account to create. That also removes the request-size ceiling most online converters impose, so long feeds and multi-megabyte exports convert as fast as your own machine can parse them.
Parse an XML response into JSON online
When an API or feed only speaks XML, converting it to JSON online makes it easy to work with in modern code. Paste an XML document or response and get structured JSON back — attributes preserved as @-keys, repeated elements collected into arrays, and optional type inference to turn numeric text into real numbers. Malformed XML is reported with the exact line and column rather than failing silently.
XML to JSON converter online — convert any XML document
This XML to JSON converter online accepts any valid XML document and produces clean, structured JSON in one step. Paste an XML string or upload an XML file; the converter validates the XML first and then transforms it — attributes become @-prefixed keys, element text content becomes a #text key, and repeated sibling elements are collected into JSON arrays.
An XML to JSON formatter is useful for working with data from SOAP APIs, RSS and Atom feeds, XML database exports, and legacy integrations. Convert XML to JSON once and work with the data using standard JSON tools instead of an XML DOM parser.
Change XML to JSON — when and why
The most common reason to change XML to JSON is to bring data from a legacy or enterprise system into a modern REST API, JavaScript frontend, or data pipeline. SOAP services, financial messages, healthcare records (HL7, C-CDA), and government data feeds use XML; REST APIs, NoSQL databases, and JavaScript code expect JSON.
To change XML to JSON here, paste your XML document and the converter outputs structured JSON immediately. Enable type inference to convert numeric and boolean text values to their native JSON types rather than keeping everything as strings. The result is ready to paste into code, a REST client, or any other tool.
Everything in the XML to JSON Converter
Convert XML to clean JSON online with attribute support, repeated-element arrays, and optional type inference. Validates your XML first. Free and in-browser.
Validation first
Malformed XML is reported with the exact line and column of the problem.
Attributes preserved
Attributes become @-prefixed keys; element text becomes #text.
Repeats to arrays
Repeated sibling elements are collected into JSON arrays automatically.
Type inference
Optionally parse numbers and booleans into real JSON types.
Frequently asked questions
Attributes become keys prefixed with @ on the element's object, and the element's text content is stored under #text when it coexists with attributes or children. This keeps the conversion lossless.
Yes. When the same tag appears multiple times under one parent, the values are collected into a JSON array, which is the natural JSON equivalent.
Yes. Turn off 'Infer types' to keep every value as a string exactly as written in the XML; turn it on to get real JSON numbers and booleans.
No. Every operation runs entirely in your browser using client-side JavaScript. Your JSON is never uploaded, logged, or stored on any server — it never leaves your device.
Yes, completely free with no sign-up required. There are no usage limits, no watermarks, and no premium gate on any feature.
Related tools
JSON to XML Converter
Convert JSON into well-formed, indented XML in one click.
YAML to JSON Converter
Convert YAML configuration into valid, formatted JSON in one click.
CSV to JSON Converter
Convert CSV, TSV, or Excel spreadsheets into a clean JSON array of objects — free and instant.
JSON to YAML Converter
Convert JSON into clean, human-friendly YAML in one click.