JSON to XML
Convert JSON to XML format.
Loading…
About JSON to XML
Systems that still expect XML need your JSON reshaped into tags. Paste an object or array and you get an indented document that starts with an XML declaration and wraps everything in a root element. Each key becomes an element, an array repeats the same element once per item, null becomes an empty tag, and ampersands and angle brackets in text are escaped. Keys that are not legal XML names are rewritten with underscores, so the output is always well-formed.
Features
- XML declaration and a root wrapper added automatically
- Arrays repeat the key's element once per item
- A top-level array, or an array inside an array, uses item elements
- Keys that are not valid XML names are rewritten with underscores
- Ampersands, angle brackets and quotes in text are escaped
- Null values become empty self-closing elements
Limitations
- No attributes are produced: a key such as @id becomes an element named _id, not an attribute.
- The wrapper element is always called root and cannot be renamed on the page.
- A one-item array and a single value look the same in XML, so converting the XML back to JSON will not recover the array.
- Download saves the text as output.txt and needs a free account, and JSON nested more than 1,000 levels deep is refused.
How it works
- Paste your JSON into the JSON Input panel.
- Select Convert to XML.
- Check the XML Output panel; it begins with the declaration and a root element.
- Copy the result with Copy Output, or use Download to save it.
- Press Clear All to convert something else.
Example input
{
"book": { "title": "Auro Guide", "tags": ["json", "xml"] }
}Frequently asked questions
- An array under a key becomes one element per item, each named after the key. A top-level array, or an array inside another array, is wrapped in an element whose children are item elements.
- Characters that XML names cannot contain are replaced with underscores, and a name that would start with a digit gets an underscore added in front. So first name becomes first_name and 2024 becomes _2024.
- No. Every key becomes a child element. If you need attributes, edit the output by hand or generate the document with code that knows your schema.
- Null becomes an empty element such as <x/>, while true, false and numbers are written as text exactly as they appear in the JSON. All values are plain text in XML, so the types are not recorded.
- No. The document is built in your browser from the text in the input panel, and nothing is sent to a server for the conversion.
