JSON to XML
input.json
output.xml
The XML appears here.
or drop a .json file into the left pane
The mapping
JSON and XML do not describe the same shapes, so any conversion has to pick a convention. This one uses the conventional mapping:
{
"book": {
"@id": "b1",
"title": "Dune",
"tag": ["scifi", "classic"]
}
}
<book id="b1">
<title>Dune</title>
<tag>scifi</tag>
<tag>classic</tag>
</book>@namebecomes an attribute.#textbecomes the element's text content, alongside its attributes.- An array repeats its parent's tag once per element.
- An empty object or array becomes a self-closing element.
Escaping
Text content escapes &, <, and >. Attribute values additionally escape double quotes and newlines, so a value containing markup or a line break cannot break out of the document it is written into.
Where the mapping loses information
XML has no numbers, booleans, or null — everything is text — so type information is gone once converted. Combined with the array idiom, this means a round trip through XML is not guaranteed to reproduce the original JSON exactly. If the round trip matters, compare the before and after with the JSON diff rather than assuming.
Going the other way
XML to JSON reads this same convention, and uses the browser's own XML parser so entities, CDATA sections, and namespace prefixes are handled properly.
Common questions
How do I produce an attribute instead of a child element?
Prefix the key with @. {"book": {"@id": "b1"}} becomes <book id="b1"/>. This is the convention used by most JSON-to-XML mappings, and the XML to JSON converter reads it back the same way.
How are arrays represented?
XML has no array type, so the element name repeats. {"tag": ["a","b"]} becomes two <tag> elements. That is the standard idiom, and it is why an array of one is indistinguishable from a plain value when read back.
What about keys that are not valid XML names?
XML names cannot start with a digit and cannot contain most punctuation. Invalid characters become underscores, and a name starting with a digit is prefixed with one — so a b becomes a_b and 2024-total becomes _2024-total. The hyphen is kept, because it is legal everywhere except the first character.
How is null represented?
As an empty element carrying null="true". XML has no null, so the alternatives are an empty element — indistinguishable from an empty string — or an explicit marker. The marker is used so the distinction survives.
The rest of the toolkit
Same engine, same privacy — every page runs entirely in your browser.
JSON formatter
Indent JSON with 2 spaces, 4 spaces, or tabs, then copy or download the result.
JSON viewer
Expand, collapse, and search a JSON tree; copy any value or its path.
JSON validator
Find syntax errors with exact line, column, and a suggested fix.
JSON minifier
Strip whitespace and see the byte savings before and after.
JSON beautifier
Turn minified or broken JSON into clean, highlighted output.
JSON pretty print
Readable indentation with optional deep key sorting.
JSON to CSV
Flatten an array of objects into spreadsheet rows, quoted correctly.
CSV to JSON
Parse CSV — quotes, embedded commas, any delimiter — into JSON records.
JSON to YAML
Config-ready YAML with no folded strings and no anchors.
YAML to JSON
YAML 1.2 parsing, multi-document streams, errors reported by line.
XML to JSON
Entities, CDATA, and namespaces handled by the browser’s XML parser.
JSON diff
Compare two documents by path — key order and indentation are ignored.