Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

JSON to XML Converter

JSON

Paste JSON, or

CtrlV paste · Ctrl↵ run now

XML
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

Convert JSON to XML: @keys become attributes, arrays repeat their element, big numbers keep every digit

Turn JSON into XML for a SOAP service, a feed or a config file. Keys marked with @ become attributes.

How to use it

  1. Paste JSON or JSON Lines on the left, or open a .json or .jsonl file.
  2. Set the root element’s name, the attribute mark, and whether the <?xml?> line comes first. Under Options: indent 2, 3, 4, tabs or Minified, the item element’s name, and CDATA.
  3. Copy or download the XML. An error names the JSON path of the value XML can’t hold.

Examples

An order with attributes and a list

Input
{"order": {"@id": "1042", "total": 28.99, "items": [{"sku": "MUG-01"}, {"sku": "TEE-07"}], "gift": false}}
Result
<?xml version="1.0" encoding="UTF-8"?>
<order id="1042">
  <total>28.99</total>
  <items>
    <sku>MUG-01</sku>
  </items>
  <items>
    <sku>TEE-07</sku>
  </items>
  <gift>false</gift>
</order>

An array repeats its element, once per item.

A list at the top, big numbers exact

Input
[{"id": 9007199254740993}, {"id": 2}]
Result
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <item>
    <id>9007199254740993</id>
  </item>
  <item>
    <id>2</id>
  </item>
</root>

JSON that isn’t one object with one key goes inside the root element; you can rename it.

How JSON becomes XML

The rules mirror XML to JSON :

  • One object with one key names the root element, unless its value is a list; anything else goes inside <root> (or the name you set).
  • Keys starting with @ (or -) become attributes; "#text" becomes the element’s text.
  • An array repeats its element; an array inside an array uses <item> elements (or the name set under Options). An empty array has no XML form, so it writes nothing, and a line above the result says how many were left out.
  • Numbers are written exactly as in the JSON, every digit kept; true and false as words; null as an empty element.
  • <, > and & in text are escaped, so the result is well-formed XML. With CDATA on, text holding < or & is written as <![CDATA[…]]> instead, a ]]> inside it split across two sections; text with a carriage return stays escaped, since readers turn it into a line feed in CDATA.
  • JSON Lines (one value a line) becomes one element a line under the root, named like array items; a line above the result says how many were read.

Questions

What happens to a key like "first name"?
XML element names can’t contain spaces or start with a digit, so the converter stops and names the key’s JSON path, like $.user["first name"], rather than renaming it silently. Rename the key and convert again.
How do I make an attribute?
Start the key with @: {"price": {"@currency": "USD", "#text": "44.95"}} gives <price currency="USD">44.95</price>. Choose -id instead if your JSON uses a dash.
Can it write CDATA sections or minified XML?
Yes, under Options. CDATA writes text that holds < or & as <![CDATA[…]]>, so code and HTML snippets read as written; Indent sets 2, 3 or 4 spaces, tabs, or Minified for everything on one line.
Is my data uploaded?
No. Everything runs in your browser, so your data stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. API responses, feeds and config files often hold keys or personal data, and the page warns you if it spots a key.

Related tools