About JSON to XML Converter
Turn a JSON object into XML for a system that only speaks XML: a legacy API, a SOAP service, an import format or a config file. Each key becomes an element, a list repeats its key once per item, and keys that start with a prefix such as @ become attributes, so {"@id": 7} gives id="7".
The result is always well formed. Special characters are escaped, keys that are not valid element names are repaired and pointed out, and characters XML cannot hold are replaced and counted rather than written into a broken file. It reads the conventions the XML to JSON converter writes, so the two undo each other.
How it works
- The JSON is parsed strictly. A syntax error is reported with its line and column instead of a half-written document.
- With Use the only key as the root on, an object with a single key that holds an object or a value uses that key as the root element. Anything else is wrapped in the root element you name.
- A list under a key writes the key once per item. A list inside a list, or at the top, writes one list item element per value. Null and empty strings become empty elements.
- Text is escaped for &, < and >, and attribute values also for quotes, tabs and line breaks, so every value reads back as the same text.
Questions
How do I make an attribute?
Start the key with the attribute prefix, @ by default: {"book": {"@id": "7", "title": "Dune"}} gives <book id="7"><title>Dune</title></book>. Keys grouped under an @attributes object work too. A key named #text becomes the element’s own text.
What happens to keys with spaces or that start with a digit?
XML element names cannot contain spaces or start with a digit, so first name becomes first_name and 1st becomes _1st. The result notes how many keys were changed.
Are numbers kept exactly?
Numbers are written as they parse in JavaScript. A whole number longer than about 15 digits cannot be held exactly, and the tool warns when it meets one; put such numbers in quotes to keep every digit.
How large a file can it convert?
Up to 5 MB of JSON, nested up to 1,000 levels deep. The conversion runs on your device as you type.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.