JSON To XML

Login

Email
Password

Don't have an account yet?

Go to Sign up

Input Data
Sample {{ showCoderInput ? 'Choose File' : 'Enter Data' }}

                                
Valid JSON Invalid JSON — Cannot convert to JSON Array
Output Data
{{ copied ? 'Copied!' : 'Copy to Clipboard' }} Download File
Properties
Convert JSON to XML online — paste, edit, and download XML.

Root Element:
Row Element:
Encoding:
Indent Size:
2 4 8 Tab
Escape XML Characters:
Escape <, >, &, ", '
XML Declaration:
Add <?xml version="1.0"?> header
Minify Output:
Remove extra whitespace
Attribute Mode:
Output as XML attributes
CDATA Wrapper:
Wrap text in CDATA sections
Convert Restart

JSON To XML Converter - Convert JSON Data to XML format Easily and Efficiently

What Are JSON and XML?

JSON (JavaScript Object Notation), defined by RFC 8259, represents data as key-value pairs and ordered lists. It is the dominant format for web APIs, configuration files, and client-server communication.  

XML (eXtensible Markup Language), defined by the W3C XML 1.0 Specification, represents data using nested elements enclosed in angle-bracket tags, with optional attributes, namespaces, and a strict well-formedness requirement. XML is used in SOAP web services, RSS/Atom feeds, configuration files (Spring, Maven, Android layouts), document formats (DOCX, SVG, XHTML), and legacy enterprise systems.  

Why Convert JSON to XML?

  • SOAP API integration — Many enterprise APIs require XML request/response bodies

  • Legacy system migration — Feed JSON-sourced data into systems that only accept XML

  • Configuration file generation — Produce XML config files from JSON templates

  • Document formats — Generate XML structures for DOCX, SVG, or Android layout files

  • RSS/Atom feed creation — Transform JSON data into syndication XML formats

  • Adobe/MS Office integration — Office Open XML formats (.docx, .xlsx) are XML-based

How JSON Maps to XML

JSON and XML have different structural models. Key differences in conversion:  

Objects Become Elements

A JSON object {"name":"Alice","age":30} maps to nested XML elements:  

<record>
 <name>Alice</name>
 <age>30</age>
</record>

Arrays Become Repeated Elements

A JSON array [1, 2, 3] maps to repeated XML elements using the row element name:  

<record>1</record>
<record>2</record>
<record>3</record>

Properties as Attributes (Attribute Mode)

With Attribute Mode enabled, object properties render as XML attributes:  

<record name="Alice" age="30"/>

This produces more compact XML and matches common XML schema patterns where identifiers and metadata are attributes while content is child elements.  

About This JSON to XML Converter

This tool runs entirely in your browser for JSON-to-XML transformation. Your data is never uploaded to any server. No data is transmitted, logged, or stored. The tool includes an Ace code editor with syntax highlighting and real-time JSON validation.  

Core Features

1. Custom Root and Row Elements

Every XML document needs a single root element. The Root Element field sets the outer wrapper tag name (default: dataset). The Row Element field sets the per-record tag name (default: record). For example, setting Root to employees and Row to employee produces <employees><employee>...</employee></employees>.  

2. XML Declaration

When enabled, the output begins with <?xml version="1.0" encoding="UTF-8"?>. This is required for well-formed XML documents and recommended when saving the output as a standalone .xml file. The encoding attribute matches the selected encoding option.  

3. XML Character Escaping

XML reserves five characters for markup: <, >, &, ", '. When enabled, the tool converts these characters in your JSON values to their entity equivalents (&lt;, &gt;, &amp;, &quot;, &apos;). Always enable this when the output will be parsed by an XML processor.  

4. CDATA Wrapper

CDATA (Character Data) sections wrap text content so that XML parsers treat it as raw character data, ignoring any markup-like characters within. A value like <script>alert(1)</script> wrapped in CDATA becomes <![CDATA[<script>alert(1)</script>]]>. Use CDATA when your JSON values contain HTML, code snippets, or arbitrary text that may include angle brackets or ampersands.  

5. Attribute Mode

When enabled, JSON object properties are rendered as XML attributes on the row element rather than as child elements. This produces more compact XML and is useful when your XML schema distinguishes between attributes (metadata/identifiers) and elements (content). Note: XML attributes cannot contain nested structures, so objects and arrays remain as child elements.  

6. Encoding Options

Three encodings are available:  

  • UTF-8 (default) — Universal, supports all Unicode characters

  • UTF-16 — For systems requiring 16-bit encoding (some Asian language environments)

  • ISO-8859-1 (Latin-1) — For legacy Western European systems

7. Configurable Indentation and Minification

Choose 2-space, 4-space, 8-space, or tab indentation for readable output. Enable Minify Output to strip all whitespace for compact, production-ready XML.  

How to Use This JSON To XML Converter?

Step 1: Provide JSON Data

Paste your JSON into the code editor, or drag and drop a .json file onto the upload area. Click Sample to load test data. The tool validates the JSON in real time — a green indicator confirms valid input.  

Step 2: Configure XML Options

In the Properties panel:  

  • Root Element — Name for the outer XML wrapper (e.g., "employees", "products")

  • Row Element — Name for each record element (e.g., "employee", "product")

  • Encoding — Select UTF-8 (default), UTF-16, or ISO-8859-1

  • Indent Size — Choose indentation for readability

  • Escape XML Characters — Enable for well-formed XML output

  • XML Declaration — Enable for standalone .xml files

  • Minify Output — Enable for compact output

  • Attribute Mode — Enable to render properties as attributes

  • CDATA Wrapper — Enable if values contain HTML or special characters

Step 3: Convert and Export

Click Convert. The XML output appears in the Output Data panel. Click Copy to Clipboard to copy the code, or Download File (Premium) to save it as a .xml file.  

JSON-to-XML Conversion Challenges

Mixed Content

XML supports mixed content (text interspersed with child elements). JSON has no equivalent. Each JSON value maps cleanly to either an element or an attribute — there is no way to represent <p>Hello <b>world</b></p> in standard JSON.  

Namespaces

XML supports namespaces (xmlns:ns="..."). JSON has no namespace concept. If you need namespace-prefixed XML output, add namespace attributes manually after conversion or use a dedicated XML schema tool.  

Null Values

JSON has null. XML has no null concept. This tool renders null values as empty elements (<field></field>) or self-closing elements (<field/>), depending on the configuration.  

Frequently Asked Questions (FAQ)

  • Is my data safe?

    All processing happens locally in your browser using JavaScript. Your files are never uploaded, transferred, or stored on any server. The tool works offline after the page loads.  

  • What JSON structures are supported?

    JSON objects, arrays, and nested combinations. Objects map to XML elements (keys become tag names). Arrays map to repeated elements. Nested objects produce nested XML elements.  

  • What is the Root Element?

    The root element is the outermost XML tag that wraps all content. Every well-formed XML document must have exactly one root element. The default is dataset — change it to match your schema (e.g., employees, products, orders).  

  • What is the Row Element?

    The row element is the tag name used for each item in a JSON array. The default is record. For example, converting a JSON array of employees, set the row element to employee so each item is wrapped in <employee>...</employee>.  

  • What is CDATA and when should I use it?

    CDATA sections tell the XML parser to treat their content as raw text, ignoring any <, >, or & characters. Enable CDATA when your JSON values contain HTML markup, code snippets, or arbitrary text with characters that would otherwise be interpreted as XML syntax.  

  • What is Attribute Mode?

    When enabled, JSON properties render as XML attributes on the parent element instead of child elements. For example, {"id":1,"name":"Alice"} becomes <record id="1" name="Alice"/> instead of <record><id>1</id><name>Alice</name></record>. Objects and arrays cannot be attributes — they remain as child elements.  

  • What is the XML Declaration?

    The XML declaration (<?xml version="1.0" encoding="UTF-8"?>) is an optional but recommended header line at the start of an XML document. It tells XML parsers the version and character encoding. Enable it when saving the output as a standalone .xml file.  

  • Can I convert XML back to JSON?

    This tool converts in one direction: JSON to XML. For the reverse, use the XML To JSON Converter on A.Tools.  

  • Why is the Convert button disabled?

    The button is disabled when the input JSON is invalid. Fix syntax errors until the validation indicator turns green.  

Featured Tools

Featured tools that you might find useful.

Popular Tools

List of popular tools that users love and frequently use.

New Tools

The latest tools added to our collection, designed for you.

Topics

The tools grouped by topics to quickly find what you need.
Free online Markdown to MATLAB array converter. Paste Markdown tables and generate valid MATLAB code in 4 formats — cell array, matrix, or struct. Runs in browser.

Markdown To MATLAB Array

Free online Markdown to MATLAB array converter. Paste Markdown tables and generate valid MATLAB code in 4 formats — cell array, matrix, or struct. Runs in browser.
Free online Markdown to MediaWiki table converter. Paste Markdown tables and generate wikitext markup with sortable headers — runs entirely in your browser.

Markdown To MediaWiki Table

Free online Markdown to MediaWiki table converter. Paste Markdown tables and generate wikitext markup with sortable headers — runs entirely in your browser.
Free Markdown to Pandas DataFrame converter. Paste Markdown tables and generate pd.DataFrame() code in 3 formats with number parsing. Runs in your browser.

Markdown To Pandas DataFrame

Free Markdown to Pandas DataFrame converter. Paste Markdown tables and generate pd.DataFrame() code in 3 formats with number parsing. Runs in your browser.
Free online Markdown to PHP array converter. Paste Markdown tables and generate valid PHP array() code with associative keys — runs entirely in your browser.

Markdown To PHP Array

Free online Markdown to PHP array converter. Paste Markdown tables and generate valid PHP array() code with associative keys — runs entirely in your browser.