Free Online XML to JSON Converter

Need to consume an XML response from a modern app? XML to JSON in one click — paste your XML, hit Convert and download a clean indented JSON tree. Runs in your browser, nothing uploaded.

or

What does an XML to JSON converter do?

XML is still the lingua franca of SOAP services, RSS feeds, financial messaging, government portals and many enterprise integrations — but most modern code, schema validators and front-end tools speak JSON. An XML to JSON converter parses the document, preserves attributes via an "@_" prefix and re-emits the same data as a JSON tree your application can consume natively.

JSON Pretty validates well-formedness, parses XML 1.0 with UTF-8 and standard encodings, and collapses repeated sibling elements into arrays. Once converted, drop the result into our JSON editor for a tree view with search and copy-by-path. New to JSON? Read the beginner's guide first.

Example

The same data, before and after conversion:

XML input
<?xml version="1.0" encoding="UTF-8"?>
<book>
  <title>JSON Pretty</title>
  <author>Eugene</author>
  <year>2026</year>
</book>
JSON output
{
  "book": {
    "title": "JSON Pretty",
    "author": "Eugene",
    "year": 2026
  }
}

How to Use

Convert XML to JSON in three simple steps — no account needed

1

Paste or upload your XML

Paste an XML document, or click "Upload file" to load a .xml file from your device.

2

Click Convert to JSON

Press Convert. The XML is validated, parsed and emitted as indented JSON with attributes prefixed by "@_".

3

Copy or download the JSON

Copy the JSON to the clipboard, or download a .json file ready for your API, code or front-end state.

Benefits of Converting XML to JSON format

Why convert XML to JSON? A few reasons it is usually the right move.

Lighter syntax for the same data
JSON drops opening and closing tags, attribute syntax, namespaces and XML escaping. The same payload usually shrinks 30 to 60 percent on the wire, with no loss of structure.
Native for REST and GraphQL APIs
Modern web APIs default to JSON. Converting an XML response once turns it into a payload your front-end, mobile app or microservice can consume directly with fetch and JSON.parse.
Direct fit for JavaScript objects
JSON deserializes into plain JS objects with one call. XML requires a parser, attribute lookups and node walks — every bit of glue code disappears once the data is JSON.
Easier to validate and diff
JSON Schema is the de facto validator for JSON; structural diffs are also cleaner. Code review tools, CI checks and merge engines produce more useful output on JSON than on XML.
Faster to parse and serialize
JSON parsers are simpler and significantly faster than XML parsers per byte. For payloads read on every request or in tight loops, switching from XML to JSON is a measurable win.

Get JSON Pretty in your browser

Format any JSON response and explore it in a clean tree view — right where you open it, no copy-paste.

4.8·40+ reviews on Chrome Web Store
Chrome iconAdd to Chrome
JSON Pretty logo

Frequently asked questions

It validates the input as well-formed XML, parses it into a JavaScript data tree and re-serializes that tree as indented JSON. Elements become object keys, text content becomes string values, and the structure of the document is preserved 1:1.

Attributes are emitted as object properties with an "@_" prefix on the element they belong to. So <book id="42"><title>...</title></book> becomes { "book": { "@_id": "42", "title": "..." } }. The matching JSON to XML converter restores the attributes when the data is round-tripped.

When the converter sees the same element name twice in a row under one parent, it collapses the siblings into a JSON array. A single occurrence becomes an object property; two or more become an array — matching how most XML-to-JSON libraries behave.

If an element has both text content and attributes, the text appears under a "#text" property and the attributes appear with the "@_" prefix. Pure text elements are simplified to a plain string value, which is the common case.

Yes. The XML declaration carries metadata (version, encoding) that the converter uses during parsing but does not include in the JSON output. Comments and processing instructions are also dropped.

Namespace prefixes ("ns:tag") are kept verbatim as JSON keys, and "xmlns" declarations appear as attributes with the "@_" prefix. The JSON is structurally identical to the XML, so any post-processing you do can stay namespace-aware.

Yes. Parsing happens entirely in your browser. Nothing is uploaded, nothing is stored, and the page works offline after the first visit.

Yes. Multi-megabyte documents parse quickly in the browser. Files with millions of elements are better handled by a streaming command-line tool, but typical configs, API responses and exports finish in well under a second.

Common causes are unclosed tags, mismatched element names, unescaped "<", ">" or "&" in text, missing quotes around attribute values, and stray characters before the root element. The error message reports the line where the validator tripped — fix it and re-run.

Yes — use the matching JSON to XML converter for the reverse direction.

Their text content is preserved — CDATA exists to escape special characters in XML, but once parsed the content is the same regardless of whether it was wrapped in CDATA or escaped inline. The JSON output contains the plain text either way.