本文へスキップ

Convert JSON to XML

Turn JSON into indented, valid XML where keys become elements, arrays repeat them and @keys become attributes; the conversion runs in your browser.

Convert to
ブラウザで動作・アップロード不要しくみ

JSON to XMLの使い方

  1. 1

    Paste the JSON

    An object, an array of records or an API response; a .json file can be dropped instead.

  2. 2

    Name the elements

    Leave the root empty to take it from the data, and set the element name used for the items of plain arrays.

  3. 3

    Download the XML

    Indented with spaces or tabs, or on one line, with or without the <?xml?> declaration.

制限と Pro

JSON files up to 500 MB; pasted text of any size your browser can hold.

JSON files up to 4 GB. Pro を見る

JSON to XML について

JSON to XML writes JSON data as an XML document for systems that still exchange XML: accounting and ERP imports, e-invoicing schemas, SOAP services, Android resources and many legacy integrations.

Every key becomes an element and every array repeats its element, so {"book": [{…}, {…}]} turns into two <book> elements side by side — the shape XML schemas usually expect. A top-level array, which XML can't have, is wrapped in a root element with one item element per entry, and a single top-level key holding an array, such as {"orders": […]}, becomes the root with singular <order> children. If the object has exactly one top-level key, that key is the root; otherwise the root is called root, or whatever name you type.

Keys starting with @ become attributes and a "#text" key becomes the element's text, the same convention the XML to JSON direction uses, so data can travel both ways. Turn on "Write simple values as attributes" for compact records such as <user id="1" name="Ann"/>.

JSON allows key names XML doesn't, so names are repaired: spaces and other invalid characters become underscores and a name starting with a digit gets an underscore in front ("1st place" → _1st_place). Text is escaped (&, < and > in content; quotes in attributes), characters XML forbids are removed, null becomes an empty element, and nested arrays get item children.

The output is UTF-8. It is well-formed XML; it isn't checked against an XSD schema, so element order and required fields are still up to your data.

プライバシー

The JSON you paste or drop is read and turned into XML by a worker in this browser tab; it isn't sent to a server or saved anywhere.

JSON to XML:よくある質問

How do I make attributes instead of child elements?
Prefix the key with @ in your JSON — the record {"@id": 5, "name": "Ann"} in an array gives <item id="5"><name>Ann</name></item>. To turn every simple value (text, number, true/false) into an attribute at once, switch on “Write simple values as attributes”; objects and arrays still become child elements because attributes can only hold text.
What will the root element be called?
When the JSON is an object with a single key, such as {"catalog": {…}}, that key becomes the root. Otherwise the converter wraps everything in <root>. Type any name in “Root element” to override both cases; invalid characters are replaced so the document stays valid.
How are arrays written in XML?
An array under a key repeats that key's element: "tag": ["a", "b"] becomes <tag>a</tag><tag>b</tag>. Arrays with no key of their own — a top-level array, or an array inside an array — get item elements, a name you can change. An empty array becomes one empty element so the key isn't lost.
Are special characters escaped?
Yes. Ampersands and angle brackets in text become &amp;, &lt; and &gt;; quotes, tabs and line breaks inside attribute values are written as character references. Control characters that XML 1.0 forbids are dropped. Letters from any alphabet, emoji included, are written as they are, since the document is UTF-8.
Can the result be validated against my XSD?
Not here — the converter produces well-formed XML but doesn't know your schema. Shape the JSON the way the schema expects (key names, order of keys, @ for attributes), convert, and validate the file with your XML editor or the receiving system. Key order in the output follows the order in your JSON.

このツールでできるほかのこと