JSON to XML converter
Convert JSON to XML that is well-formed. Keys starting with "@_" become attributes and "#text" becomes element text, so XML converted with this site round-trips cleanly.
What you get
- Convert JSON to XML online that is always well-formed: invalid element names are fixed and named, and special characters are escaped.
- JSON to XML with attributes: keys starting with "@_" become attributes and "#text" becomes element text, so XML you converted to JSON here converts back the same.
- Checked: the XML is parsed back and compared with your data, value by value.
- Choose the root and item element names, and 2 spaces, 4 spaces or no indentation.
- Open a JSON file to XML in one step, or paste JSON, and download the .xml file.
- Private and free: everything runs in your browser, nothing is uploaded, and there is no sign-up.
How each result is checked
- The output is checked for well-formedness with an XML validator.
- The XML is parsed back and compared with your data. Because XML has no data types, values are compared as text.
What can't convert exactly
- XML has no numbers, booleans or null: they are written as text, and null becomes an empty element.
- Keys that are not valid XML names (spaces, leading digits) are renamed, and you are told which.
- A one-item array looks the same as a single value in XML, and empty arrays have no XML form.
Questions
How do I make an attribute?
Prefix the key with "@_", for example { "book": { "@_id": "bk101", "title": "…" } } gives <book id="bk101">.
What if my JSON has several top-level keys?
XML needs a single root element, so the data is wrapped in <root> (you can rename it in the options).
How do I convert JSON to XML with a root element?
XML needs one root element. If your JSON has one top-level key, it becomes the root; otherwise the data is wrapped in <root>, and you can rename it and the array item element in the options.
How do I convert JSON to XML online?
Paste your JSON or open a file on the left (or click Example). The XML appears on the right as you type, already checked. Copy it, or download it as a file. Nothing is uploaded.
Can the XML output be wrong?
Every result is checked before it is shown (the checks are listed on this page). If a check fails, the page says "Review needed" and why, instead of presenting the output as correct, and anything that cannot convert exactly is named in the notes.