input
output
Convert JSON to XML, or paste XML to convert it back to JSON.

Convert JSON to XML and XML to JSON

Paste JSON and click To XML, or paste XML and click To JSON. The converter uses a small explicit mapping so attributes, text and repeated elements can be represented in a JSON object . The processing is done in the browser.

The mapping rules

  • Attributes<note id="1"> becomes { "note": { "@id": "1" } }.
  • Text nodes — text is stored under #text when the element also has attributes or child elements.
  • Repeated elements — siblings with the same tag name become an array.
  • Arrays — JSON array items become repeated elements with the same name.
  • Entities — the five predefined XML entities and numeric character references are decoded on XML input; reserved text is escaped on XML output.

These conventions are common, but there is no universal lossless mapping between XML and JSON. Namespaces, mixed text and child ordering, processing instructions, DTDs, comments and attributes are all things that can be represented in XML that a plain JSON object cannot preserve. This converter is most suitable for regular data-oriented XML.

Choose a root and inspect the result

When a JSON object has exactly one suitable top-level property, that property becomes the XML document element. Other values are wrapped in a <root> element, and a top-level array becomes repeated <item> elements beneath it. Confirm that this shape matches the system receiving the XML.

The XML reader is intentionally lightweight and best-effort. Do not cite a successful conversion as evidence that XML is well-formed, schema-valid, namespace-correct, or resistant to hostile XML. Use an XML-aware library and the correct XSD or other contract to validate key documents.

If the JSON side contains familiar syntax mistakes, the tool attempts a repair before conversion. For the details behind each direction, see Converting CSV and XML to JSON, or review the input first with JSON Fix.

FAQ

How do I make a JSON value an XML attribute?

Prefix the key with @, for example "@id": "1". Use #text for an element's text when the same object also contains attributes or child elements.

Does conversion validate my XML?

No. It offers a handy structured view for typical data XML, but it is not a strict well-formedness, namespace, DTD or XSD validator.

Will XML-to-JSON-to-XML reproduce the original bytes?

No. Formatting, comments, processing instructions, namespace details, and mixed-content order may change or be omitted. Compare the semantic data you need, not a byte-to-byte round trip.