Home Developer Tools JSON to XML

JSON to XML Converter - Attributes & Live Tree

Convert JSON to XML with real control - map @key fields to XML attributes, set a custom root element, choose how arrays become repeated elements, and preview the result as an interactive tree alongside the raw XML.

Always Free Live tree preview Attribute mapping Runs in browser
Custom root · @attributes · CDATA · Array modes
Interactive tree preview of your XML structure
@-prefixed keys become real XML attributes
Configurable root element, arrays, and indentation
Basic object With attributes (@id) Arrays Deeply nested
Map @keys to attributes
XML declaration
CDATA for text
JSON input
0 bytes
Drop JSON file here
XML output
-

XML output appears here

Paste JSON or load a sample to begin

Other converters guess.
This one gives you control.

Real attribute mapping, a configurable root element, array handling options, and a live tree you can explore - not just a wall of angle brackets.

Interactive tree preview

Explore your XML as a collapsible tree - click any element to expand or collapse its children, just like a file browser.

click to expand/collapse

Real attribute mapping

@id becomes a true XML attribute, not a child element - following the convention used by Newtonsoft, FreeFormatter, and most XML libraries.

@key → attribute

Custom root element

Name your root element to match your API resource - <Order>, <Catalog>, whatever your schema needs.

type any name

Array handling modes

Choose repeated elements (<tag>...</tag><tag>...</tag>) or wrapped <item> containers - toggle to compare both.

2 array modes

CDATA support

Wrap text content in <![CDATA[ ]]> so HTML, code, or special characters in your JSON strings don't need escaping.

raw text preserved

Plain-English errors

Invalid JSON shows the exact line and column with a clear explanation - no cryptic parser messages.

line + column shown

Convert JSON to XML in 3 steps

Handles attributes, arrays, and deep nesting.

1

Paste or upload JSON

Paste a JSON object or array, or drag and drop a .json file. Invalid JSON is flagged with line and column immediately.

2

Configure the output

Set a root element name, decide how arrays are represented, toggle attribute mapping, indentation, and CDATA.

3

Explore & export

Browse the interactive tree to verify structure, then copy the raw XML or download it as a .xml file.

JSON to XML - the conventions that matter

JSON and XML represent data very differently. JSON has objects, arrays, and primitive types. XML has elements, attributes, and text content - with no native concept of arrays or booleans. Converting between them means making a series of conventions explicit, and getting them right is the difference between XML that "looks okay" and XML that actually validates against a schema.

Attributes vs elements - the @ convention

The most common convention, used by Newtonsoft's Json.NET, FreeFormatter, and most JSON-XML libraries, is to prefix a key with @ to mark it as an XML attribute rather than a child element. So:

{"@id": "42", "name": "Rahul"}

becomes:

<root id="42"><name>Rahul</name></root>

When an element needs both attributes and text content, a special #text key holds the text value alongside the @-prefixed attributes.

Arrays - XML's biggest gap

XML has no array type. A JSON array like "tags": ["new", "sale"] is conventionally represented as repeated elements with the same tag name: <tags>new</tags><tags>sale</tags>. Some schemas instead expect array items wrapped in a generic container, like <tags><item>new</item><item>sale</item></tags>. This tool supports both - pick whichever matches the schema you're integrating with.

Booleans, numbers, and null in XML

XML text content is always a string - there's no native boolean or number type. A JSON true becomes the text true, and a JSON null becomes an empty element. If the system consuming your XML needs typed values, it typically uses an xsi:type attribute or a separate schema (XSD) to specify expected types - this is outside what a generic converter can infer.

When should I use CDATA? If your JSON string values contain characters like <, >, or & - for example, HTML snippets or code samples - these normally need to be escaped as &lt;, &gt;, and &amp; in XML. Enabling CDATA wraps the text in <![CDATA[ ... ]]> instead, telling the XML parser to treat everything inside as literal text with no escaping needed.
JSONXML output
{"name":"Rahul"}<root><name>Rahul</name></root>
{"@id":"42","name":"Rahul"}<root id="42"><name>Rahul</name></root>
{"tags":["a","b"]}<root><tags>a</tags><tags>b</tags></root>
{"active":true}<root><active>true</active></root>
{"note":null}<root><note/></root>

Legacy system integration

Many banking, insurance, and government systems still require XML - convert modern JSON APIs to feed them.

SOAP & WSDL

Generate XML fragments that match the structure expected by SOAP-based web services.

RSS & feed formats

Convert structured data into XML for RSS, Atom, or sitemap-style feeds.

Config files

Some build tools and frameworks (Maven, Spring, MSBuild) use XML configuration - convert JSON config drafts to XML.

Format migration

Migrating from an XML-based system to JSON, or vice versa - use this alongside an XML to JSON tool for round trips.

Learning XML structure

See how familiar JSON data maps to XML elements and attributes - useful for understanding XML schemas.

JSON to XML questions,
answered.

Everything about attributes, arrays, and XML conventions.

Ask a question
Paste your JSON into the input box or upload a .json file. The tool converts each key into an XML element, wraps the whole structure in a root element you can name, and shows the result as both a live tree and raw XML you can copy or download.
XML has no native array type, so each item in a JSON array becomes a repeated element with the same tag name as the array's key. For example, a "tags" array with two items becomes two <tags> elements. You can also choose to wrap repeated elements inside an <item> container using the array mode dropdown.
Prefix a JSON key with @ to mark it as an XML attribute instead of a child element. For example, {"@id": "42", "name": "Rahul"} becomes <element id="42"><name>Rahul</name></element>. This follows the same convention used by most JSON-XML libraries. Try the "With attributes" sample to see it in action.
When an XML element needs both attributes and text content, use a #text key for the element's text value alongside @-prefixed attribute keys. For example, {"@id":"1","#text":"Hello"} becomes <element id="1">Hello</element>.
Yes. By default the root element is named "root", but you can change it to anything valid in XML, such as the name of your API resource or document type, using the Root element field in the controls bar.
CDATA sections tell an XML parser to treat content as raw text without interpreting special characters like < and &. Enable the CDATA option if your JSON string values contain HTML, code snippets, or other characters that would otherwise need escaping.
No. All conversion happens locally in your browser using JavaScript. Your JSON data never leaves your device and is never stored anywhere.