JSON1 / JSON to XML
JSON to XML
Convert JSON to indented XML. Arrays repeat the parent tag, nulls become xsi:nil, and keys that are not legal element names are sanitised.
Processed locally·Your data never leaves your device
InputJSON
ReadyOutputXML
Converted output appears here as you type.
About this tool
XML is still what SOAP services, enterprise integrations, and document formats like DOCX and RSS expect. Converting JSON to it means resolving a genuine mismatch rather than reformatting: JSON has arrays and a real null, XML has neither, and XML has attributes, which JSON does not.
Four rules cover the whole conversion:
[]An array repeats the parent tag once per element. XML models lists by repetition, so there is nothing else to map it to.nullBecomes an empty element carrying xsi:nil="true", with the xmlns:xsi namespace declared on the root — and only when a null is actually present.2faA key that is not a legal element name is sanitised: spaces become underscores, and a leading digit gets an underscore in front of it.<root>A top-level array is wrapped, with each element as <item>, because a document with several root elements is not well-formed.
Nothing here writes attributes. Every JSON key becomes a child element, which is verbose but unambiguous — the alternative is guessing which keys were "really" attributes, and a wrong guess is silent.
- Why is my array not visible as an array?
- XML has no array type. A list of three items is the same element three times over, which is the conventional encoding — but it means a one-element array and a plain value are indistinguishable in the output. Converting back gives you the scalar, not a list of one.
- Is the xsi:nil output actually valid?
- Yes.
xsiis a namespace prefix, and using one without declaring it is a namespace error even though the document parses — soxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"goes on the root element whenever a null appears. Documents with no nulls do not carry a declaration they never use. - What happens to a key like "first name" or "2fa"?
- They become
first_nameand_2fa. Element names cannot contain spaces or start with a digit, so there is no faithful option — and the rewrite is not reversible, which is worth knowing before treating this as a storage format rather than a hand-off. - Are the values escaped?
- Text is escaped for
&,<, and>, so a value containing markup stays a value. Those three are the ones that would break the document; quotes are only special inside attributes, and nothing here writes attributes.
Related tools
- XML to JSONConvert XML to formatted JSON. Attributes become @name keys, repeated elements collapse into arrays, and mixed text lands under #text.
- JSON to TOMLConvert JSON to TOML. Nested objects become tables, arrays of objects become table arrays, and everything else inlines.
- JSON to JavaGenerate Java classes with Jackson annotations from a JSON sample. Optional primitives are boxed, so an absent field stays distinct from zero or false.