XML to JSON Converter Online — Free & Private

SOAP, RSS or sitemap chunks become REST-friendly structures, with readable error messages.

Loading…
XML → JSON conversion rules
Explains how attributes, text and repeated elements are written as JSON.

Developer notes

The XML declaration is removed, and the root element becomes the single top-level key. Attributes become keys of the element. Text next to attributes or child elements goes under _text. Elements with the same name become an array, while a single element stays an object. Every value is a string, including numbers and booleans, because XML has no types. Comments are dropped, and mixed content is flattened.

Use cases

Mock fetch() responses from a SOAP export. Compare configuration before a move to REST. Explore XML data with JSON tools.

About these options

For CSV output, choose the delimiter, how fields are quoted, the line endings and whether to write a header row. Auto uses a comma in English and a semicolon in French, German and Spanish, as Excel expects. For CSV input, the delimiter is detected on the first line (comma, semicolon, tab or pipe). You choose whether that line holds the column names. JSON output can use 2 or 4 spaces or a single line, with an optional recursive key sort. XML output can be pretty-printed with a chosen indent width. YAML output takes an indent width and a quoting mode for strings. XML comments are dropped, because the conversion goes through a JSON tree.

Examples

Attributes next to child elements

Input

<?xml version="1.0" encoding="UTF-8"?> <config env="production" region="eu-west"> <database> <host>db-primary.internal</host> <port>5432</port> <name>checkout</name> <ssl enabled="true" /> </database> <cache ttl="300"> <redis host="cache.internal" port="6379" /> </cache> <features> <flag name="checkout-v2" enabled="true" rollout="25" /> <flag name="dark-mode" enabled="false" /> </features> </config>

Output

{ "config": { "env": "production", "region": "eu-west", "database": { "host": "db-primary.internal", "port": "5432", "name": "checkout", "ssl": { "enabled": "true" } }, "cache": { "ttl": "300", "redis": { "host": "cache.internal", "port": "6379" } }, "features": { "flag": [ { "name": "checkout-v2", "enabled": "true", "rollout": "25" }, { "name": "dark-mode", "enabled": "false" } ] } } }

Repeated elements become an array

Input

<catalog> <book><title>Alpha</title><year>2020</year></book> <book><title>Beta</title><year>2022</year></book> <book><title>Gamma</title><year>2024</year></book> </catalog>

Output

{ "catalog": { "book": [ { "title": "Alpha", "year": "2020" }, { "title": "Beta", "year": "2022" }, { "title": "Gamma", "year": "2024" } ] } }

Related tools

Go the other way with JSON → XML, shrink files with the XML minifier or convert to YAML with XML → YAML.

XML → JSON FAQ

Browser parsing

How is this different from xmllint?

It uses the browser DOMParser, which suits snippets and files of moderate size, not gigabyte dumps.

Is the XML validated against a schema?

No. Only well-formedness is checked, and an invalid document stops with an error.

Is CDATA kept?

The text inside CDATA is kept as text. The CDATA markers themselves do not appear in the JSON.

Is my data sent to a server?

No. The conversion runs in your browser, and FastMinify never receives what you paste.

Convert XML to YAML, CSV, JSON, TOML, TSV and HTML.