🔄 JSON ↔ XML Converter

Convert between JSON and XML instantly in your browser — format, minify, validate, and copy with one click.

Samples:
JSON Input
Ready Lines: 0 Chars: 0 Size: 0 B
XML Output
Lines: 0 Chars: 0 Size: 0 B
Conversion Options
JSON → XML
Root element name
Array item element name
Indent size
Output
JSON indent (output)

JSON ↔ XML Conversion Guide

Structural Differences

JSON supports arrays natively with [] while XML represents them as repeated sibling elements. JSON has no concept of attributes — everything is a key-value pair. XML supports mixed content (text + child elements), which has no direct JSON equivalent.

Root Element Requirement

XML requires a single root element. When converting a JSON object, the root key becomes the XML root. When converting a JSON array (which has no named root), a synthetic root element name like <root> is needed to produce valid XML.

Type Coercion

XML is entirely text-based — all values are strings. When converting XML → JSON, numeric strings like "42" and boolean strings like "true" can be coerced to their native JSON types. Use the "Auto-detect" option to enable this, or "Keep as strings" for lossless round-tripping.

XML Attributes

XML attributes (e.g. <item id="5">) have no JSON counterpart. This converter maps them to JSON keys with a configurable prefix (default @), so id="5" becomes "@id": "5". When converting JSON → XML, keys with the @ prefix become XML attributes.