Root:
Indent:
Attr prefix:
JSON Input 0 B
Ready
0 chars
XML Output 0 B
XML output will appear here...
0 chars
Features

Why use this converter

Attribute support

Keys prefixed with @ (configurable) become XML attributes instead of child elements. Useful for metadata like @id, @type, @href.

Array handling

Each array item is rendered with the parent key as the element name. "roles":["a","b"] becomes two <roles> elements.

Proper escaping

All text content is escaped for XML: &, <, >, ", '. Output is always well-formed XML.

How it works

Conversion explained

1. Parse JSON

Input is parsed into a JavaScript value. Invalid JSON produces a clear error.

2. Walk and emit

The converter walks the value recursively. For each object, it separates attribute keys (prefixed with @) from child element keys, then emits the appropriate XML.

3. XML declaration

The output begins with <?xml version="1.0" encoding="UTF-8"?> by default.

FAQ

JSON to XML Converter — frequently asked questions

How are arrays represented in XML?

Each item in a JSON array becomes a separate XML element with the parent key as its name. For example, "tags":["a","b","c"] becomes three <tags> elements.

How do I add XML attributes?

Use the @ prefix (configurable) on a key. For example, {"user":{"@id":"123","name":"Ada"}} produces <user id="123"><name>Ada</name></user>.

Why doesn't XML support all JSON types directly?

XML is a markup language, not a data format. It has no native concept of null, boolean, or number types — everything is text. JSONLab renders null as null="true" attribute, booleans as their string form.

Can I convert XML back to JSON?

Yes — use the XML to JSON tool. The conversion is reversible for the subset of XML that JSONLab produces.