toolgarden.xyz
中文

JSON ↔ XML

Free online JSON to XML and XML to JSON converter

JSON

XML

About this tool

JSON models keyed values and arrays, while XML models elements, attributes, and text nodes. There is no single universal mapping between them, so the output follows a convention rather than preserving every source formatting detail.

The tool is intended for ordinary API and configuration documents. Repeated sibling elements usually become arrays, while attributes and element text need distinct fields. Namespaces, mixed content, and CDATA-heavy XML require extra review after conversion.

How to use it

  1. Choose the source format

    Select JSON to XML or XML to JSON and enter a complete root object or root element.

  2. Convert the structure

    The parser builds a tree and reports missing brackets, quotes, or closing tags before producing output.

  3. Review repeated nodes and attributes

    Confirm arrays, attributes, text nodes, and namespace prefixes match the contract expected downstream.

Input and output example

Note the type loss on the XML side: both 3 and true become plain text, and converting back relies on inference.

JSON
{
  "book": { "id": 3, "title": "SQL", "inStock": true }
}
XML
<book>
  <id>3</id>
  <title>SQL</title>
  <inStock>true</inStock>
</book>

Supported range and limits

Directions
JSON to XML and XML to JSON
Structural mismatch
JSON has native arrays and XML does not; arrays need an agreed wrapper element
Type loss
Everything in XML is text. Numbers, booleans and null lose their type, and converting back relies on inference
Attributes vs elements
XML attributes usually map to prefixed keys in JSON, so a round trip may not reproduce the original document exactly
Namespaces
Namespace prefixes survive as part of the key name, but the semantics are no longer understood by a parser
Typical use
SOAP APIs, legacy systems, and industry standards that exchange XML

When you would use it

  • Calling a legacy XML service

    Turn application JSON into an XML request body without hand-writing every tag and escape.

  • Inspecting configuration or responses

    Convert deeply nested XML to JSON so existing JavaScript tooling can traverse and validate it.

  • Migrating XML configuration to a JSON stack

    Converting a legacy system's XML config to JSON lets modern tooling consume it while the old parsing code is retired gradually.

What to know before you start

  • Attributes, text, and child elements can collide in name. Complex XML needs a mapping contract shared with the receiver.
  • JSON nulls, numbers, and booleans usually become XML text and may not recover the original type on a round trip.
  • Element order can carry meaning in XML, while business logic should not normally depend on JSON object key order.

Related concepts

attribute
A key-value pair written in an opening tag, such as id in <item id="7">.
mixed content
An XML element containing both text and child elements, where ordinary JSON mappings can lose ordering information.

Frequently asked questions

Can it convert both JSON to XML and XML to JSON?
Yes. It supports both directions; paste either JSON or XML and the other format is produced.
How are attributes and nested nodes handled?
XML elements map to JSON keys and nested structures keep their hierarchy; converting back to XML rebuilds tags from the object levels.
Does converting upload my data?
No. JSON ↔ XML conversion runs locally in your browser and nothing is uploaded.
Why does a round trip not reproduce the original?
The two formats are not equally expressive. JSON has no notion of attributes or namespaces; XML has no native arrays or types. Bridging those gaps takes a convention, and any mismatch with the original document shows up as a difference.
Why does my array look strange in XML?
XML has no array type, so it is expressed as repeated same-named elements, usually inside a wrapper. Conventions for that wrapper vary between tools, so confirm the expected structure with whoever consumes it.