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

CSV exports: choose a delimiter (Auto follows locale — semicolon on /fr), RFC-minimal vs always-quoted fields, line endings, and whether to emit a header row. CSV imports: delimiter is auto-detected from the first line (comma, semicolon, tab, or pipe) — toggle whether row 1 holds column names. JSON output (XML, YAML, or CSV sources): indentation (including compact one-line) and optional recursive key sort. JSON → XML: toggle pretty-printing and indent width. YAML output: indent width, readable vs tighter layout, and deterministic string quoting (there is no source YAML file to “preserve”). XML comments are not represented in the intermediate 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.