What JSON to XML does, and when you need it
JSON and XML both hold data as plain text. JSON writes names and values in curly brackets, {"city": "Pune"}, and is what most web apps make today. XML wraps each value in tags, <city>Pune</city>, and is still what many older systems, portals and file formats expect. This page turns JSON into XML by fixed rules, shown below, so the same JSON always gives the same XML.
Where it helps:
- A portal, a bank's system or an older program that only accepts XML, when your data comes from an app as JSON.
- A SOAP service, which speaks XML, fed from a JSON API.
- An import into an accounting program that reads XML.
- A feed or a report built with XML tools, such as XSLT, from JSON data.
The result is well-formed XML, with the XML declaration at the top, that any XML reader accepts. It is made in your browser, in a background worker, and never uploaded.
How to convert JSON to XML, step by step
- Paste JSON in the box, or press Try a sample for a made-up order, and press Convert to XML (or Ctrl+Enter).
- Or choose files: press Choose files, or drop .json files anywhere on the page. Each one is converted at once, in a row of its own.
- Choose the root element and the indent, explained below. Leave Root element empty to use the JSON's own top name when it has one.
- Read the line on the result: for the sample, “<order>, 16 elements”, with a note for each name that was made safe, such as “delivery note” becoming <delivery_note>.
- Copy or Download. A file keeps its name, so orders.json becomes orders.xml; JSON you pasted is saved as data.xml. Two or more results can be saved together with Download all as ZIP.
How JSON becomes XML: the rules
Every file is converted by the same rules, the reverse of XML to JSON's, so XML made there and turned into JSON comes back the same way.
| In the JSON | In the XML |
|---|---|
One name at the top whose value isn't a list {"order": {...}} | The main element <order> |
| Anything else: a list, several names, or a single value | Everything inside <root>, and the result says why |
| A name typed in Root element | Always the main element, with the JSON inside it |
"@id": 17 | An attribute id="17" |
"#text": "hello" | The element's text |
"city": "Pune" | <city>Pune</city> |
"item": ["a", "b"] | <item>a</item><item>b</item>: a list repeats the element |
| A list inside a list, or a list at the top | <item> elements |
null or "" | An empty element <note/> |
An empty list [] | No element; the result counts them |
true, 42, 3.50 | Their text, numbers exactly as written: 3.50 stays 3.50 |
| An object or list as an attribute or #text | Written as JSON text, and the result says so |
&, <, > and " | &, <, > and, in attributes, " |
| Control characters XML can't hold | Left out, and counted in the result |
The XML starts with <?xml version="1.0" encoding="UTF-8"?>. Names keep their order, and an element's text comes before its child elements.
Names XML can't hold, made safe
A JSON name can be anything; an XML name can't hold spaces or most punctuation, or start with a digit. Such names are changed the same way every time, and the result lists the first few:
| JSON name | XML name |
|---|---|
first name | first_name: each character an XML name can't hold becomes _ |
rate% | rate_ |
2024 | _2024: a name that starts with a digit, - or . gets _ in front |
An empty name "" | _ |
a:b | a_b, unless "@xmlns:a" on that element or one above declares the prefix a; then it stays a:b |
नाम | नाम: Hindi and other letters are fine in XML names |
| Two attributes that end up with the same name | The second gets _2 |
Real results from our tests
We tested JSON to XML with headless Chromium 148, the open-source browser Chrome is built on, on a Windows laptop with an Intel Core i7-1185G7 and 32 GB of memory, on 1 November 2026. Other work was running on the laptop at the same time, so times vary a little from run to run: each time below is the middle one of 3 runs, each in a fresh browser.
Checked against Python. Our test gave the page every file of our test set for this tool, 15 that it should convert and 13 with mistakes, with the usual options and again with changed ones, and then the 50 MB file: 57 files in all. For every converted file, every saved XML was well-formed for Python's own XML reader (expat), with and without namespaces, started with the XML declaration, and held the elements, attributes and text the page's rules make from what Python's json module read. Each of the 13 files with mistakes was refused, as Python refuses it too, with the page's message naming the mistake.
Speed and memory. The test files were made up for these tests: a list of orders, of 1 MB, 10 MB and 50 MB. The time is from choosing the file to its finished row, and the memory is what the whole browser added while it worked. “Page kept waiting” is the most that a timer on the page, set to tick every 50 milliseconds, was ever late: the work runs in a background worker, so the page itself stays free to answer a tap or a click.
| File | Time | Result | Memory added | Page kept waiting |
|---|---|---|---|---|
| A 1.0 MB JSON file | 0.1 s | 1.5 MB | 0 MB | 5 ms |
| A 10 MB JSON file | 0.7 s | 15 MB | 165 MB | 11 ms |
| A 50 MB JSON file | 4.0 s | 75 MB | 767 MB | 8 ms |
| A 1.0 MB JSON file, on a phone-sized screen with the processor slowed 4 times | 0.4 s | 1.5 MB | 3 MB | 126 ms |
| A 10 MB JSON file, on a phone-sized screen with the processor slowed 4 times | 1.6 s | 15 MB | 174 MB | 114 ms |
What the numbers mean: a 50 MB file took 4.0 seconds on the laptop, and the page was never kept waiting for more than 8 milliseconds while it worked, far too little to notice. With the processor slowed 4 times, roughly a mid-range phone, a 10 MB file took 1.6 seconds, and the page was never kept waiting for more than 126 milliseconds: on a phone, a big result's box starts closed and is filled when you open it, so the finished row appears at once.
The root element and indent
An XML file must have exactly one main element, the root, around everything else; JSON has no such rule. So when the JSON has one name at the top whose value isn't a list, like the sample's {"order": {...}}, that name becomes the root, <order>. In every other case, a list, several top-level names, or a single value, everything goes inside <root>, and the result says why: for a list, “Everything is inside <root>, because the JSON is a list.”
Type a name in Root element to choose it yourself, such as the name a portal's documentation asks for: it then always wraps the JSON, and it is made safe by the same rules as other names. Indent sets the layout: 2 spaces, 4 spaces, a tab, or one line for the smallest file. Changing either never redoes a finished result by itself: it says it was made before the change and offers a button such as “Redo with 4 spaces”.
Big files: up to 200 MB
The work runs in a background worker, a separate part of the browser, so the page keeps responding while a big file is read and written. In our tests a 50 MB file, a list of orders, took 4.0 seconds on a laptop, and the page was never kept waiting for more than 8 milliseconds. A big file needs memory, though: the browser used 767 MB more while it worked, so on a phone or an older computer a file of a few tens of MB is the comfortable size. Stop, or the × on a row, ends the work at once.
The result box shows the start of a big result, the first 20,000 characters; Download always saves all of it, and Copy works up to 10 MB. Files over 200 MB are not started, because a browser tab would run out of memory: split them first. On a phone, a big result's box starts closed, so its row, with Download and Copy, appears at once: tap Result to see the start of it.
When the JSON has a mistake
JSON with a mistake isn't guessed at. The row names the mistake with its line and column and shows the line with a ^ under the place; for JSON in the box, Show in the box puts the cursor there. The usual ones:
- A comma after the last item,
{"a": 1,}: “There is a comma after the last name and value here. JSON doesn't allow that: remove the comma.” - Single quotes,
{'a': 1}: “Names must be in double quotes ("name"), not single quotes.” - A missing comma,
{"a": 1 "b": 2}: “A comma is missing before this name.” - A comment: “JSON can't hold comments (// or /* */). Remove the comment.”
- Python's True or None, from a print rather than json.dumps: “true and false are written in small letters in JSON: true.” and “None isn't allowed in JSON. Use null, or a number.”
- A name without quotes,
{a: 1}: “Names must be in double quotes: "a".”
To check JSON on its own, with the same messages, use JSON Formatter.
A worked example: the sample order
The sample is a made-up order in JSON. With Root element empty, it becomes this XML:
{"order": {...}}has one name at the top, so<order>is the root, and its"@id"and"@date"becomeid="INV-2026-0417" date="2026-10-09"."item": [ {...}, {...} ]makes two<item>elements, each withsku="..."from its"@sku", and<title>,<qty>and<price>inside; 180.00 stays 180.00."delivery note"has a space, which an XML name can't hold, so it becomes<delivery_note>, and its & is written&."paid": truebecomes<paid>true</paid>, and"coupon": nullan empty<coupon/>.
The result is 515 bytes, 16 elements, with one note: the renamed name. Typing export in Root element puts the same order inside <export>.
Lists, empty values and nesting
JSON lists have no direct match in XML, which repeats an element instead. So "phone": ["98...", "99..."] gives two <phone> elements one after the other, and a program reading the XML sees two phones. A list inside a list has no name for its items, so they become <item>: "rows": [[1, 2], [3, 4]] gives two <rows>, each with two <item>.
Empty values need care, because XML can't tell some of them apart. null and an empty text both make an empty element, <coupon/>, while an empty list makes no element at all, and the result counts those. If a receiving program needs to see an element that is empty, give it null or "" rather than [].
Making XML a portal or a program will accept
A system that takes XML usually describes exactly what it wants, often in a schema (an XSD file) or a sample file: the root's name, the names and order of elements, which values are attributes. The page makes well-formed XML from whatever names your JSON has; it doesn't know any schema. So the way to get XML a portal accepts is to shape the JSON first:
- Use the element names from the portal's sample, in the same order.
- Put @ in front of the names that the sample has as attributes.
- Type the sample's root name in Root element.
Then compare the result with the sample file side by side, for example with Text Compare, before you upload it to the portal.
Attributes, text and child elements
XML has two places for a value, an attribute in the start tag or an element of its own, and JSON has only names. The page uses a common convention: a name that starts with @ becomes an attribute, and the name #text becomes the element's own text. So {"order": {"@id": 17, "#text": "hello", "a": 1}} gives <order id="17">hello <a>1</a></order>: the attribute in the tag, the text first, then the child element.
An attribute can only hold text, so an object or a list given as an attribute or as #text is written as JSON text inside it, and the result says so. Choose attributes for short facts about an element, such as an id, a date or a currency, and elements for the data itself; when a portal's sample file shows which is which, follow it.
Special characters and escaping
Some characters have a job in XML, so inside text they are written as codes: & as &, < as < and > as >, and in attributes " as ". Any XML reader turns them back into the characters, so Leave it at the gate & ring twice reads as the sample's note. A few control characters, invisible codes that XML can't hold at all, are left out, and the result counts them. Everything else, Hindi, emoji and accented letters among them, is written as it is in UTF-8.
Private: your data stays on your device
Your JSON never leaves your device. The converter runs inside your browser, in a background worker on your own phone or computer, and has no upload step: it never sends your file or the text you paste anywhere. The page's Content Security Policy lets it contact only this site and Google's ad service, which pays for the site; our code never gives your files to the ad code. You can check it yourself in your browser's network panel (F12 on a computer): converting a file adds no request that carries it.
Nothing you paste is run as code. The JSON is read by our own small reader, written for this site, which only reads text: there is no eval and no step that runs anything from the file.
Compared with converters that upload your file
| This page | A converter that uploads | |
|---|---|---|
| Where your file goes | Nowhere: it is converted in your browser | To the site's server |
| Size | Up to 200 MB | Often a few MB |
| The rules | Shown on this page, the reverse of XML to JSON's | Often not stated |
| Names XML can't hold | Made safe the same way every time, and listed | Varies; some make invalid XML |
| Numbers | Every digit as written | Some round long numbers |
| Offline and sign-up | Works once loaded; no sign-up | Needs the internet; sometimes an account |
Tips for XML other programs accept
- Give the root the name the receiving program expects: its documentation or an example file shows it.
- Write "@name" for a value that must be an attribute, and "#text" for an element's own text.
- Check the result by turning it back with XML to JSON: the same rules in reverse give your JSON again.
- A list of one item still makes one element, and an empty list makes none, so a program that needs the element should get at least one item.
- Keep IDs in quotes in your JSON if a program reads them as text; the page writes numbers exactly as they are either way.
- Data in a spreadsheet? Save it as CSV UTF-8, make JSON from it with CSV to JSON, and convert that here.
Limits
- Files up to 200 MB. Bigger files are not started: a browser tab would run out of memory.
- No schema. The XML follows the rules on this page, not a schema (XSD) a program may need: rename elements there if it asks for other names.
- Empty lists make no element, and null and empty text both make an empty element, so XML can't tell them apart.
- Nesting deeper than 500 levels (an object or list inside another, 500 times over) isn't read.
- Comments and CDATA aren't written: text is escaped instead.
JSON and XML terms, explained
- JSON
- JavaScript Object Notation: data written as text, with names and values in { } and lists in [ ].
- XML
- Extensible Markup Language: data written as text with tags, like <city>Pune</city>.
- Root element
- The one element around everything else in an XML file.
- Attribute
- A name="value" in a start tag, like id="17" in <order id="17">; in the JSON, a name that starts with @.
- Well-formed
- XML any XML reader accepts: tags closed in the right order, one root element, valid names, & and < escaped.
- Escaping
- Writing & as & and < as < so that they aren't read as markup.
- Namespace
- A prefix like gst: tied to an address with xmlns:gst="...", so that names from different sources can't clash.