esc
JSON → XML

JSON to XML:
Converter

JSON to XML. Free, private, instant.

JSON to CSVYAMLTOON Reverse XML → JSON

How to convert JSON to XML

  1. 01Add JSON filesChoose files or drop them on the page.
  2. 02Converted on your deviceNothing is uploaded. Adjust settings if you like.
  3. 03DownloadSave each file, or all of them as one ZIP.

Reach for this JSON to XML converter when a system still expects tagged data, such as an older API, a SOAP service, a product feed or an XML config file. Objects become nested elements, lists become repeated elements, and the output starts with a standard UTF-8 XML declaration. Your file is converted locally and never uploaded.

How JSON becomes XML: a worked example

Take this input: {"order": {"@_id": 7, "customer": {"name": "Ana", "city": "Lyon"}, "items": [{"sku": "A1"}, {"sku": "B2"}]}}. The file has a single top-level key holding an object, so order becomes the root element. The output is <order id="7"> containing a <customer> element with <name>Ana</name> and <city>Lyon</city> inside it, followed by two <items> elements, one for each entry in the list.

A list repeats its key once per entry rather than adding a wrapper with <item> children, which is how most XML formats write lists. The output is indented with two spaces.

The root element, attributes and text

  • Root. When the JSON is one key holding an object, that key is the root. Anything else is wrapped in <root>: an object with several top-level keys, a single value, or an array, whose entries each become an <item> element.
  • Attributes. Keys that start with @_ become attributes, so "@_currency": "EUR" turns into currency="EUR". An @_ key holding an object or a list is skipped, because an attribute can only hold a plain value.
  • Element text. A key named #text becomes the element’s own text, so {"price": {"@_currency": "EUR", "#text": 9.5}} gives <price currency="EUR">9.5</price>.
  • XML to JSON uses the same conventions, so its output converts back into similar XML here.

Edge cases the converter handles

  • Keys that aren’t valid XML names. Element names can’t contain spaces or most punctuation, or start with a digit. Those characters become underscores and a leading underscore is added where needed, so "first name" becomes first_name and "2nd" becomes _2nd.
  • Colons. A colon also becomes an underscore, so dc:title comes out as dc_title. Attribute keys are left alone, so "@_xmlns:dc" still works as a namespace declaration.
  • Special characters. &, < and > inside values are escaped as &amp;, &lt; and &gt;, so the document stays valid.
  • null and empty values. null and empty objects become self-closing elements such as <note/>. An empty list produces no element at all.
  • Lists inside lists. A value like [[1, 2], [3, 4]] can’t be written as plain repeated elements, so each inner list gets its own <item> children.

Matching a format someone else defined

There’s no schema, so the converter can’t know whether a system wants a value as an attribute or a child element. To match an existing format, adjust the JSON first: add @_ to keys that should be attributes, and wrap everything in one key named after the expected root element.

Invalid JSON is rejected with the line and column of the problem, usually a missing or trailing comma or a missing quote. JSON with // comments isn’t valid JSON either.

Need a spreadsheet instead? JSON to CSV flattens records into rows. For config files people edit by hand, JSON to YAML is easier to read than XML.

Guides

JSON vs CSV vs XML: which to use and how to convertA plain-English comparison of JSON, CSV and XML: what each is good at, when to pick which, and how to convert between them without losing data.

At a glance

Price
Free. No sign-up, no watermark.
Privacy
Files are processed in your browser and never uploaded.
Accepts
JSON
You get
XML
Batch
Convert many files at once and download them as a ZIP
Works in
Chrome, Edge, Firefox and Safari, on phones and computers
Offline
After the first conversion, it keeps working without internet

Questions

Are my files uploaded?

Never. JSON to XML conversion runs in your browser, so your files stay on your device.

Can I convert many at once?

Yes. Add as many as you like and download them all as one ZIP.

Is there a size limit?

Files of tens of megabytes are fine on most computers.

Why is my data wrapped in a <root> element?

Because the JSON doesn’t have exactly one top-level key holding an object. Wrap your data in one, such as {"catalog": {...}}, and catalog becomes the root.

How do I get an attribute instead of a child element?

Start the key with @_. For example "@_id": 7 becomes id="7" on the parent element.

Does it add a schema or namespaces?

No, only an XML declaration and the elements. Add namespaces yourself as @_xmlns keys.

Can any JSON be converted to XML?

Any valid JSON converts, but some shapes need adjusting along the way. Several top-level keys, a bare value or an array are wrapped in a <root> element, characters that aren’t allowed in XML names become underscores, and lists inside lists get <item> children.