JSON to XML Converter
Convert JSON to clean XML with your own root and item names, optional attributes and a declaration. Free, and it runs entirely in your browser.
1 name was changed because XML does not allow it:
2024- becomes
_2024
What is a JSON to XML converter?
A JSON to XML converter rewrites JSON data as XML. Each key becomes an element, and each value goes between that element’s opening and closing tags. You need this when one side of a project speaks JSON and the other side only reads XML, which still happens with older web services, invoice and accounting systems, feed formats and many enterprise tools.
Writing the XML by hand is slow, and it is easy to forget to escape an & or a < sign. This converter handles those details. Text is escaped so the output is always well formed, and characters that XML 1.0 does not allow are dropped.
Here is how the pieces map. An object becomes an element with child elements, one for each key, in the same order as your JSON. An array repeats its element once for each item, so a key “tag” holding three values gives three tag elements. Numbers, true and false are written as text, and numbers keep their exact digits, so a long ID is never rounded. A null value becomes an empty element.
XML is stricter than JSON about names. An element name cannot start with a digit, cannot contain spaces and cannot begin with the letters “xml” in any mix of capitals. JSON keys can be almost anything, so the converter fixes names that would break the XML. A key “2024” becomes “_2024”, and a space or other odd character becomes an underscore. Every renamed key is listed under the result, so nothing changes without you knowing.
You can also choose the name of the outer element, the name used for items of a top-level array, the indentation, and whether to start with an XML declaration. If your data uses keys that begin with “@”, the tool can turn those into attributes instead of child elements.
Everything runs in your browser. Your JSON is not sent anywhere, which matters when it holds tokens, customer details or other private data.
How to use the JSON to XML converter
- Paste your JSON into the input box. A sample is already there so you can see how the output looks.
- Change Root element if you do not want the default “root”, and Item element for array items if your JSON starts with an array.
- Choose the indentation, and tick the box if you want the XML declaration on the first line.
- Tick the attribute option if keys starting with “@” should become attributes.
- Read the XML in the XML box and check the list of renamed keys under it, if there is one.
- Copy the result with the copy button.
FAQ
Why was one of my keys renamed?
XML element names follow strict rules. They cannot start with a digit or with “xml”, and they cannot contain spaces or most symbols. When a key breaks one of these rules, the converter adds an underscore in front or replaces the bad characters with underscores, then shows the old and new name under the result.
How are arrays converted?
Each item of an array becomes its own element with the name of the key that held the array. If the whole JSON is an array, each item is wrapped in an element named by the item name you choose, which is “item” by default.
Can I turn keys into XML attributes?
Yes. Tick the attribute option and write the keys you want as attributes with an “@” in front, for example a key “@id” next to the other fields. Those keys become attributes on their parent element instead of child elements.
Why do I get an error about my JSON?
The converter needs valid JSON first. Comments, trailing commas and single quotes are common causes. Fix the spot the message points to, or run the text through a JSON formatter to find the problem.
Does it handle very deep JSON?
It handles nesting up to one thousand levels without crashing. Deeper data is very rare and is reported as an error instead of freezing the page.
Is my data sent to a server?
No. The conversion happens on your own device inside the page. Nothing is uploaded and nothing is kept after you close the tab.