JSON to XML Converter
Well-Formed XML in One Paste
Paste your data here for a quick and easy JSON to XML conversion. It will return valid XML with a root element, and name each element safely.
- FreePrice
- XML 1.0Output
- NoneSign-up
- In your browserRuns
JSON to XML Converter
Converted in your browser, with every issue listed
- Records
- 0
- Depth
- 0
- Size
- 0 B
Ready. Paste your data, open a file or try the sample.
| Result | Check | Details |
|---|
Going the other way? Convert XML to JSON
Jobs This JSON to XML Converter Does It All
This tool converts JSON objects, lists, and values to XML, writing the data as elements. Each key becomes a tag and each value is enclosed by the tag. The conversion occurs within your browser, ensuring that your data is not sent anywhere.
At first, the two formats look alike. Still, each of them follows its own set of rules. XML must have a single root element, whereas JSON may begin with a list. XML elements must have matching tags. Elements in an XML document can carry attributes. JSON does not have attributes at all. XML elements can sit inside other elements.
A good conversion makes a few decisions and lists them in the checks table included in the result. This means you always have a clear idea about why the resulting XML looks a certain way.
How JSON Turns Into XML Elements
An object becomes an element with child elements, one for each key. A plain value becomes the text for the element. A list behaves differently because there is no list type in XML. In this case, the element repeats itself, so a key book with three items becomes three book elements.
Two special keys provide additional control. A key starting with @ (e.g. @id) makes that attribute part of the parent element. A key #text sets the element's text content. With these keys, almost any XML shape can be represented in JSON.
Choosing the Root Element
Each XML document begins with a single outer element and everything else is contained within that element. If your JSON already has a single top-level key, such as {"catalog": {...}}, the key becomes the root element, and the tool adds nothing else.

When the JSON begins with a list or multiple keys, the converter adds a root element for you and names it root by default. Replace it with anything that you prefer (i.e. orders or products). A list at the top also gets an item element for each entry, so every record remains separate.
Convert JSON to XML With Safe Tag Names
JSON keys often break XML naming rules. A key like first name has a space, 2024 starts with a digit, and price($) contains symbols. Any of these would make the XML invalid, so the parser at the other end would refuse the whole file.

The converter repairs such names instead. A run of spaces or symbols becomes one underscore, so first name turns into first_name and price($) into price. A leading digit gets an underscore in front, while letters from any language stay as they are. It then lists the keys it changed in the checks, so no name changes without you knowing. The rules it follows come from the W3C XML specification.
Special Characters and Escaping
Some characters mean something in XML. In XML, & opens an entity and < opens a tag. Therefore the converter writes them as & and < inside text, and it escapes quotes inside attributes. The result opens cleanly in any XML reader.
Accents, emoji and all other script are untouched because the tool saves the file as UTF-8. The top declaration states this explicitly. You can turn it off if the XML is to be embedded in some other document.
Attributes or Elements: Which to Use
They both hold data, so the choice is usually what the receiving system expects. Attributes generally contain shorter labels for an element, e.g., an id, a language or a currency. Elements generally hold the actual data, e.g., a list that may repeat, or a structured data e.g., an employee record.
Namespaces behave in the same way. Add a key like @xmlns:g with the corresponding namespace address. Use a prefixed key like g:price. The converter preserves them, so product feeds and other namespaced formats will be converted correctly.
When the JSON Itself Has an Error
The converter reads your JSON strictly, following RFC 8259. A trailing comma, a single quote or a missing bracket stops the conversion with the exact line and column. One click on Show me where puts the cursor on the problem.

JSON to XML Online, for Real Work
XML is still everywhere behind the scenes. Banks and payment gateways exchange it. Many shipping, invoicing and government systems accept nothing else. Sitemaps and RSS feeds are XML too, which is why our XML sitemap generator writes it.
Meanwhile, most modern APIs use JSON. So developers are often found between the two, pulling JSON from one service and pushing XML to another. This tool sorts that out in a few seconds. And going the other way around is just one click away on the XML to JSON page.
A Quick Walkthrough of the JSON to XML Converter
This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.
Turning JSON Into XML on Denwix
Most files finish converting before you finish reading the checks.
JSONs can be pasted into the Denwix box, or .json files can be opened
The input box accepts pastes, can have .json files dropped on it, or can open .json files. The sample shows attributes and lists in action.
Name the root
Enter the outer element name if the JSON is a list or has multiple keys. The tool finds it otherwise.
Set the layout
Select to keep or remove the XML declaration. Keep or remove tabs, 2, 4 spaces or one line.
Check and take it
Compare what was changed. Copy the XML or save the changes to a file.
XML That Other Systems Accept
A converter is only useful if the receiving system can read what it writes.
Always one root
This tool encapsulates lists and multi-key objects to keep the document in a well formed state.
Attributes from @keys
Write id or currency as real attributes, the way many schemas expect.
Legal tag names
The tool identifies and fills gaps in spaces, digits and symbols and then lists each repair.
Correct escaping
The converter escapes &, < and quotes so the XML stays valid.
Exact numbers
Long IDs and Prices are kept exactly as they are in JSON.
Private by default
Your Payloads remain within the browser, even for the largest files.
Rules for JSON That Becomes Good XML
Mold your JSON correctly and the XML comes out in the form that a partner system expects.
- Wrap the data in one named key. When the top key becomes invoice, then the tool adds no generic wrapper.
- Use singular names for list keys. Items are elemental in XML and read more naturally that way.
- Keep keys free of spaces. Use first_name or firstName. These tags maintain their exact names.
- Mark attributes with @. Attributes can only be simple values, so lists and objects should be maintained as child elements.
- Use #text for mixed elements. An element with attributes and text needs its text under the #text key.
- Match the target schema. If a partner sent you an XSD file, compare tag names and order against it.
- Avoid empty lists. Some schemas treat an empty list as missing data, writing no elements at all.
- Save files with the XML declaration. Standalone files should have the XML declaration at the beginning, and embedded fragments shouldn't.
Six JSON to XML Mistakes
The following will produce XML that strict parsers will reject or read incorrectly.
More than one root
There are two top-level issues that make the file invalid, in spite of how well organized it looks.
Tags starting with digits
Something like 2024 can't be a tag name without being changed.
Unescaped ampersands
Smith & Sons, for instance, breaks every parser if written raw.
Lists squashed into one tag
Breaking list items into one text value covers up the individual records.
Objects as attributes
An attribute holds one simple value, never a nested structure.
Forgetting the encoding
A file saved in another encoding garbles every accented name.
Questions About the Denwix JSON to XML Converter
How does the Denwix JSON to XML conversion work?
You can upload your JSON or copy/paste it into the box, and Denwix will automatically convert it to XML and provide it next to the JSON for easy copying and/or downloading.
How can I create an XML attribute?
Key values are indicated with @. The value for id is indicated as "@id": "bk101" and appears as id="bk101" on the parent element.
How do JSON arrays turn into XML?
Items are represented as separate elements with the same tag name. XML does not have a list type. Repeated elements are the standard way to represent lists.
Why was my data wrapped in a root element?
XML can only have one outer element. Your JSON started with a list or a few keys, so it was wrapped. You can rename it.
Why did the name of a tag change?
Perhaps the original key broke the rules of XML naming, e.g. with a space or a digit at the start. The checks list all such changes.
How are null values written in the XML?
A null becomes an empty element, such as <phone/>. That keeps the field present without inventing a value.
Is it mandatory to have a declaration line in XML?
Not always. Standalone files should have it, but you can turn it off when XML is embedded in a different document.
Can I turn the XML result back into JSON later?
Yes. When the XML to JSON converter reads attributes, it puts them as @keys and repeated tags as lists. That keeps the data in the same shape.
Why do ampersands look different in XML?
Inside text of an XML document, an ampersand should be written as an HTML entity like this: &. Any XML reader will decode it back to an ampersand, so your data will stay the same.
Can the output be formatted as an RSS feed or sitemap?
If you can format your JSON that way. Put channel or urlset as the single top key, add the required name space with a @xmlns key and the output keeps the names as is.
Can the Denwix converter write XML namespaces?
Yes. Declare the namespace with a key such as @xmlns:g, then use prefixed keys like g:price. Both pass through unchanged.
How large a file will this Denwix tool accept?
Files of many megabytes are not a problem. Large data sets are written to disk when the button is pressed, as opposed to being written, byte-by-byte, as the user types.
Does the JSON I paste ever leave this Denwix page?
No. Conversion happens on your browser only. This site and no other server receives the data.
More Free Tools for Data Formats
Handy on either side of the conversion.
- XML to JSON Converter
Read XML back into JSON with attributes and lists.
- JSON Formatter
Find and correct JSON errors before you convert.
- CSV to JSON Converter
Start from a spreadsheet and get JSON records first.
Ready to Turn Your JSON Into XML?
Paste JSON and valid XML appears immediately. You don’t need an account, it’s free, and the data stays in your browser. The converter from JSON to XML is online.