JSON to XML

Convert JSON data into XML format, turning one structured data format into the other. No signup. Ideal for when a system or context needs XML rather than JSON.

Upload File

Result

Share on Social Media:

Paste your JSON into this free JSON to XML converter and get clean, indented XML in seconds — with an XML declaration on top and everything wrapped in a fixed <root> element. It runs entirely in your browser, with no account, no install and no upload: you can also load JSON from a .json file or from a URL.

On this page

  1. How to Convert JSON to XML Step by Step
  2. What JSON and XML Are
  3. Why Convert JSON to XML
  4. Who Converts JSON to XML
  5. Pro Tips for JSON to XML
  6. Common JSON to XML Mistakes to Avoid
  7. Related Tools You May Need Next
  8. Frequently Asked Questions

How to Convert JSON to XML Step by Step

  1. Paste your JSON into the editor. The input is a code editor, so your JSON keeps its highlighting and structure. It starts empty — there is no sample to delete first. Make sure the JSON is valid: a missing comma or an extra bracket stops the conversion.
  2. Or load it another way. Click Upload File to load a .json file from your computer, or paste a public JSON address into the Load from URL box — the tool fetches it and puts the JSON into the editor for you.
  3. Click "Json to XML". That single button is the whole conversion. There are no settings to choose — no root name, no indentation option, nothing to configure.
  4. Read the Result. The result appears below the editor: your XML, starting with an XML declaration, everything nested under a <root> element and indented with tabs. The page scrolls down to it automatically.
  5. Copy it or save it. Click Copy to Clipboard to copy the whole result, or Save as TXT to download it as a file. Note the download is named json-to-xml.txt — rename it to .xml if the system you are feeding needs that extension.
  6. Check it before you use it. Read the output once: confirm the structure, the repeated elements and any empty tags match what your target system expects, especially if your JSON had arrays or null values.

JSON structure being converted into an XML tree

What JSON and XML Are

JSON and XML are two ways of writing the same structured data. JSON is compact: keys and values in curly braces, arrays in square brackets. XML is tag-based: every value sits between an opening and a closing tag, nested in a hierarchy. They can hold the same information — this tool rewrites one as the other.

Your JSONWhat the XML looks like
Object key with a string, number or boolean valueAn element with that text: {"age": 30} → <age>30</age>. Numbers and booleans become plain text (9.99, true, false).
Nested objectNested elements, indented one tab per level.
Array of valuesThe element is repeated once per item: {"tags": ["red", "green"]} → <tags>red</tags> then <tags>green</tags>.
Array of objectsThe element is repeated, once per object, each holding that object's fields.
null as an object valueA self-closing tag: {"note": null} → <note/>.
Empty string ""An empty element: <a></a>.
Empty array []A self-closing tag: <items/>.
Key starting with _ inside an objectBecomes an attribute, in single quotes: {"person": {"_id": "42", "name": "Ada"}} → <person id='42'><name>Ada</name></person>.
__text key inside an objectBecomes the element's text: {"a": {"__text": "hello", "_x": "1"}} → <a x='1'>hello</a>.
__cdata key inside an objectBecomes a real CDATA section: <![CDATA[...]]>.
Special characters in values (& < > ")Escaped automatically: &amp;, &lt;, &gt;, &quot;.
Top-level string, number or booleanBare text inside <root> — so convert an object, not a bare value, for a useful result.

The output always looks the same. Every conversion starts with <?xml version="1.0" encoding="UTF-8" ?>, then a <root> element holding your data, then </root>. The root is always literally <root> — you cannot rename it — and nesting is indented with tabs.

Worked example: a book object, converted for real

Paste this JSON:

{"book": {"title": "Dune", "authors": ["Frank Herbert", "Brian Herbert"], "price": 9.99, "available": true, "note": null}}

Click "Json to XML" and you get exactly this — 11 lines:

LineGenerated XML
1<?xml version="1.0" encoding="UTF-8" ?>
2<root>
3<book>
4  <title>Dune</title>
5  <authors>Frank Herbert</authors>
6  <authors>Brian Herbert</authors>
7  <price>9.99</price>
8  <available>true</available>
9  <note/>
10</book>
11</root>

Three things to notice: the two-author array became two repeated <authors> elements; 9.99 and true became plain text; and the null became a self-closing <note/>. The top-level elements sit at the left margin and each deeper level gains one tab of indent.

A monitor showing structured code data

Why Convert JSON to XML

You convert when the other side needs XML. Plenty of systems still speak XML only — older APIs, SOAP services, enterprise tools, configuration files, RSS and sitemaps — and if your data is in JSON, converting is the bridge. JSON is easier to write by hand; XML is what those systems will accept.

AspectJSONXML
StructureKeys, values and nesting in bracesTags in a nested hierarchy
SyntaxCompact — {"name": "Ada"}Verbose — <name>Ada</name>
ArraysSquare brackets, one listRepeated elements, one per item
AttributesNo native attributes — use a key like "_id"Native attributes on any element
CommentsNone — JSON has no comments<!-- comments --> are supported
Best forWeb APIs, JavaScript, config you edit by handLegacy systems, SOAP, documents, feeds

What this tool does — and what it does not do

It doesIt does not do
Convert pasted JSON, a .json file, or JSON from a URLLet you rename the <root> element — it is always <root>
Repeat an element once per array itemOffer indentation or formatting settings — tabs, always
Turn _-prefixed keys into attributesValidate its own XML output — check it yourself before use
Escape & < > " in valuesConvert several files at once — one conversion per run
Copy the result or save it as a fileSend your JSON to a server — the conversion runs in your browser

Who Converts JSON to XML

Developers feeding a legacy system. An API or service that only accepts XML gets your JSON data converted into the format it expects.

API integrators. Moving data between a modern JSON API and an older XML-based partner, one payload at a time.

QA and testers. Producing XML test payloads from JSON fixtures to check how a system handles them.

Data migrators. Turning JSON exports into XML for import into tools that read XML configuration or data files.

Students and learners. Seeing, side by side, how the same data looks in JSON and in XML — arrays, nesting, nulls and all.

Data being processed into layered structured documents

Pro Tips for JSON to XML

Check your JSON is valid first. Paste it into the JSON Validator before converting. Invalid JSON shows an error message and no result at all — the editor will not guess what you meant.

Use "_"-prefixed keys for attributes. If your target XML needs <person id="42">, write {"person": {"_id": "42", ...}}. Put the _ key inside an object — at the top level it has nothing to attach to and disappears.

Rename the saved file. "Save as TXT" downloads json-to-xml.txt. The contents are XML, so rename it to .xml if the system you are feeding expects that extension.

Paste directly when a URL load does nothing. Loading from a URL only works for a public address that returns JSON and allows cross-origin requests. If nothing appears in the editor, copy the JSON from the source and paste it in instead.

Keep keys valid XML names. Letters, digits (not first), hyphens, underscores and dots are safe. Spaces and leading digits make tags a strict XML parser will reject.

Always read the output before using it. The conversion is mechanical: arrays repeat, nulls become empty tags, and the root is always <root>. A quick read catches the one case your target system will not accept.

Common JSON to XML Mistakes to Avoid

Pasting invalid JSON and expecting a result. A trailing comma, a missing quote or an unclosed brace shows an error message and produces no XML. Fix the JSON first — the JSON Formatter can tidy it, but it will not repair broken syntax for you.

Putting nulls directly inside arrays. A null sitting in an array — {"items": ["a", null]} — stops the conversion with no result and no message. Remove the null or replace it with an empty string first. (A null as a field of an object is fine — it becomes a self-closing tag.)

Converting a bare top-level array. [{"a": 1}, {"a": 2}] becomes <0> and <1> elements, which are not valid XML names. Wrap the array in an object first, e.g. {"items": [...]}.

Using keys with spaces or leading digits. "first name" becomes <first name> and "2fa" becomes <2fa> — neither is a valid XML tag. Rename the keys before converting.

Putting attribute keys at the top level. A top-level "_id" key is silently dropped — it has no element to belong to. Attributes only work inside a nested object, like {"person": {"_id": "42"}}.

Expecting the saved file to be ".xml". "Save as TXT" downloads json-to-xml.txt. If you hand that filename to a tool expecting .xml, rename it first.

Expecting URL loading to work on any site. The address must be public, must return JSON, and must allow cross-origin requests. A page that returns HTML, or a server that blocks cross-origin fetches, loads nothing — with no error shown.

Related Tools You May Need Next

Prepare the JSON, convert it, then check the XML:

XML to JSON — convert back the other way, from XML to JSON. JSON Validator — confirm your JSON is valid before converting. JSON Formatter — tidy JSON into a readable layout first. JSON Viewer — read and navigate large JSON before converting it. JSON Editor — edit JSON in a full editor. JSON Beautifier — pretty-print JSON. JSON Minify — shrink JSON by removing whitespace. JSON Escape — escape or unescape JSON strings. JSON to CSV — the same JSON as a spreadsheet instead. JSON to YAML — the same JSON as YAML instead. CSV to JSON — build JSON from a CSV first, then convert it. XML Formatter — tidy the XML output afterwards. Schema Markup Generator — structured data for your pages.

Frequently Asked Questions

How do I convert JSON to XML?

Paste your JSON into the editor and click "Json to XML". The result appears below the editor — XML with a declaration on top and your data under a <root> element. Then copy it with Copy to Clipboard or download it with Save as TXT.

Do I need an account or anything installed?

No. The converter is free, needs no signup and nothing to install, and the conversion runs in your browser on any device.

What does the XML output look like?

It always starts with <?xml version="1.0" encoding="UTF-8" ?>, then a <root> element holding your converted data, indented with tabs. The root is always literally <root> — you cannot rename it.

How are arrays converted?

An array becomes a repeated element, once per item: {"tags": ["red", "green"]} gives <tags>red</tags> followed by <tags>green</tags>. Arrays of objects work the same way, one element per object.

How do I add an XML attribute?

Start the key with an underscore inside an object: {"person": {"_id": "42", "name": "Ada"}} becomes <person id='42'><name>Ada</name></person>. Note the attribute uses single quotes, and a top-level underscore key is dropped, so keep attributes inside an object.

What happens to null values?

A null that is a field of an object becomes a self-closing tag, e.g. <note/>. But a null sitting directly inside an array stops the conversion with no result — remove it or replace it with an empty string first.

Can I load JSON from a file or a URL?

Yes. Click Upload File for a .json file, or paste a public JSON address into Load from URL. The URL must return JSON and allow cross-origin requests; if nothing appears in the editor, paste the JSON directly instead.

Why did nothing happen when I clicked convert?

Two usual causes: the JSON is invalid, in which case an error message appears and no result is shown — fix the JSON and try again; or the JSON contains a null directly inside an array, which stops the conversion silently — remove that null first.

Is my JSON uploaded to a server?

No. The conversion runs in your browser with JavaScript; your pasted JSON is never sent to SEOMagnate's server. The only network request the tool makes is the optional "Load from URL" fetch, which goes to the address you entered.

Can I convert XML back to JSON?

Yes — use the XML to JSON tool, which converts in the opposite direction.