XML ⇄ JSON Converter

Client-sideNo sign-upFree

Convert XML to JSON or JSON to XML in either direction, entirely in your browser.

Quick facts

Category
Converters
Best for
Converting a legacy XML config or SOAP response into JSON for scripting
XML
JSON
✗ Loading...
Attributes become "@name" keys and text content becomes "#text" when an element also has attributes or children - repeated child tags become a JSON array. Just need to reformat XML or JSON, not convert between them? See the XML Formatter or JSON Formatter.
In-content slot
Was this tool helpful?
On this page

Overview

Convert XML to JSON or JSON back to XML with a single click, filling a real gap on this site: XML formatting and JSON formatting already exist as separate tools, but neither actually converts between the two formats. Attributes become "@name" keys, text content alongside attributes or child elements becomes a "#text" key, and repeated child tags become a JSON array - a common, readable mapping (though XML and JSON have no single official conversion standard, so any converter is making structural choices, and this one documents its own). Useful for reading a SOAP response or legacy XML config as JSON for easier scripting, or producing XML output from a JSON API for a system that still expects it. Parsing and serialization both use the browser’s native DOMParser and XMLSerializer rather than a hand-rolled string parser, so malformed XML is caught the same way a real XML consumer would catch it. Runs entirely client-side.

Best for: Converting a legacy XML config or SOAP response into JSON for scripting

How to use this tool

  1. Pick a direction. Switch between XML → JSON and JSON → XML with one click.
  2. Paste your input. Drop in XML or JSON - the sample updates to match whichever direction is selected.
  3. Read the converted output. The result updates live as you type, using the attribute/text/array convention described below.
  4. Swap and repeat. Use the swap button to feed the output straight back in as new input.

Why use this tool

Fills a real gap

XML and JSON formatting already exist separately on this site - this is the missing direct conversion between them.

Native browser parsing

Uses DOMParser and XMLSerializer rather than a hand-rolled string parser, so malformed XML is caught reliably.

Documented, consistent convention

Attributes, text content, and repeated tags map to JSON the same way every time, since XML↔JSON has no single official standard.

Nothing leaves your browser

Conversion happens entirely client-side - useful when the XML or JSON contains real API or config data.

Frequently asked questions

XML attributes and element text/children live in different places conceptually, but JSON only has one namespace per object - prefixing attributes with "@" keeps them from colliding with a child element of the same name, which is the convention most XML-to-JSON tools use.

JSON-to-XML conversion here expects the JSON to have exactly one top-level key, which becomes the XML root element - JSON objects with multiple top-level keys or a top-level array don’t have an unambiguous single root to convert to, since XML requires exactly one root element.

No - the XML Formatter and JSON Formatter each reformat a document within its own format (indent, validate). This tool converts between the two formats entirely, which is a different operation with its own structural mapping decisions.

Explore more free tools

Formatters, converters, validators, and generators - all free and running entirely in your browser.

Browse more tools