Skip to content

JSON to XML Converter

Convert JSON to well-formed XML in your browser using the @attribute, #text and array convention. Set the root and item element names, validate or rename invalid keys, choose indentation, and copy or download the escaped XML.

Text & Document Runs client-side Free to use
Jump to the tool
Share: X WhatsApp
Loading JSON to XML Converter…

About the JSON to XML Converter

JSON to XML Converter builds a well-formed XML document from JSON, using the same convention as the XML to JSON Converter. Object keys become elements; keys starting with @ become attributes; "#text" becomes the element’s text; arrays repeat their key as sibling elements; and null becomes an empty element. Strings, numbers and true/false are written as escaped text, so nothing you paste is ever treated as markup.

You set the root element name, and the element name used for root arrays and arrays nested inside arrays. If the JSON is an object with a single top-level key — the shape XML to JSON produces — that key can be used as the root. Every element and attribute name is checked against XML naming rules; invalid keys stop the conversion unless you choose to rename them, in which case the renamed keys are listed. The finished XML is re-parsed by your browser’s XML parser to confirm it is well-formed.

How to use

  1. Paste JSON or open a .json file.
  2. Set the root element and array item names.
  3. Choose indentation and whether to include the XML declaration.
  4. Press Convert to XML and review any renamed keys.
  5. Copy the XML or download the .xml file.

Key features

  • Same @attribute, #text and array convention as XML to JSON.
  • Correct escaping of text and attribute values.
  • XML name validation with optional, listed renaming.
  • Nested objects and arrays converted predictably.
  • Indentation of 2 or 4 spaces, tabs or none.
  • Well-formedness check of the result and a structure preview.
  • Copy XML and Download .xml.

Best practices

  • Use @ keys only for simple values; attributes cannot hold objects or arrays.
  • Declare namespace prefixes with an "@xmlns:prefix" key.
  • Prefer renaming keys in your JSON over automatic renaming for long-term use.
  • Use no indentation when whitespace between elements matters.
  • Validate the XML against your schema in your own toolchain if one applies.

Benefits

  • Produces XML for older systems and feeds from JSON data.
  • Safe output: values are always escaped.
  • Round-trips predictably with the XML to JSON Converter.
  • Private: runs entirely in your browser.

Frequently asked questions

How are arrays converted?

An array repeats its key: {"b": [1, 2]} becomes <b>1</b><b>2</b>. A root array, and an array directly inside another array, use the array item element name (item by default).

How do I create attributes and text?

Start the key with @ for an attribute, for example "@id": "7", and use "#text" for the element’s own text. Attributes must be simple values, not objects or arrays.

What happens to invalid key names?

XML names cannot contain spaces or most symbols and cannot start with a digit. By default the conversion stops and names the key. If you choose “Rename them”, invalid characters become _ (and a leading _ is added where needed), and every renamed key is listed.

Are special characters escaped?

Yes. &, < and > are escaped in text; attribute values also escape quotes, tabs and line breaks. Control characters that XML 1.0 cannot contain are reported as an error.

How are namespaces handled?

Keys such as dc:title are allowed when the prefix is declared with an "@xmlns:dc" key on the same or a parent object. Undeclared prefixes are reported because the result would not be valid XML.

Will converting back give me the same JSON?

Often, but not always. Numbers and true/false become text, null becomes an empty element, and indentation adds whitespace around mixed text, so XML and JSON do not preserve each other perfectly.

What are the limits?

Up to 5 MB of JSON with 100 levels of nesting, and up to 20 MB of generated XML.

Is my data uploaded or saved?

No. Pasted text and opened files are processed in your browser on your device. Nothing is uploaded, and data, settings and results are not saved in browser storage. Reset clears them from the page.