JSON to XML Converter

Input JSON

Output XML

Your XML appears here as you type.

Paste data to see token savings

XML is required for legacy systems, SOAP APIs, and certain document formats.

Example: JSON input and real XML output

The output below was generated by the same conversion code the converter uses, run on this sample when the page was built.

JSON input (791 characters)
{
  "response": {
    "orders": [
      {
        "id": 1001,
        "status": "shipped",
        "total": 59.9,
        "customer": {
          "name": "Ana Ruiz",
          "country": "ES"
        },
        "items": [
          "SKU-104",
          "SKU-221"
        ]
      },
      {
        "id": 1002,
        "status": "pending",
        "total": 18.5,
        "customer": {
          "name": "Jonas Berg",
          "country": "SE"
        },
        "items": [
          "SKU-310"
        ]
      },
      {
        "id": 1003,
        "status": "shipped",
        "total": 112,
        "customer": {
          "name": "Mei Tanaka",
          "country": "JP"
        },
        "items": [
          "SKU-104",
          "SKU-415",
          "SKU-502"
        ]
      }
    ]
  }
}
XML output (730 characters)
<response>
  <orders>
    <id>1001</id>
    <status>shipped</status>
    <total>59.9</total>
    <customer>
      <name>Ana Ruiz</name>
      <country>ES</country>
    </customer>
    <items>SKU-104</items>
    <items>SKU-221</items>
  </orders>
  <orders>
    <id>1002</id>
    <status>pending</status>
    <total>18.5</total>
    <customer>
      <name>Jonas Berg</name>
      <country>SE</country>
    </customer>
    <items>SKU-310</items>
  </orders>
  <orders>
    <id>1003</id>
    <status>shipped</status>
    <total>112</total>
    <customer>
      <name>Mei Tanaka</name>
      <country>JP</country>
    </customer>
    <items>SKU-104</items>
    <items>SKU-415</items>
    <items>SKU-502</items>
  </orders>
</response>

XML output is 8% smaller than the JSON input. The same data is 388 characters as minified JSON and 791 as pretty-printed JSON. Sizes are character counts, not tokens: token counts depend on the model's tokenizer (see the tokenizer comparison).

JSON to XML: what changes

  • The orders array becomes repeated <orders> elements and the items array becomes repeated <items> elements. Rename array keys to singular nouns before converting if you want <order> and <item> tags.
  • Reading JSON: Input must be strict JSON: no comments, trailing commas, or single quotes. If it came from an LLM or a log file, run it through the JSON repair tool first.
  • Writing XML: XML needs exactly one root element. Several top-level keys, or a top-level key holding an array, produce sibling roots that are not well-formed XML, which is why this sample is wrapped in a single key. Keys prefixed with @_ become attributes.

About JSON

JavaScript Object Notation is the most widely used data interchange format. Lightweight, easy to parse, and supported by every programming language.

  • ✓Universal compatibility
  • ✓Easy to parse
  • ✓Great for APIs
  • ✓Native in JavaScript
Full JSON Documentation →

About XML

Extensible Markup Language is a verbose but powerful format. Still widely used in legacy systems, SOAP APIs, and document formats.

  • ✓Rich metadata
  • ✓Namespaces
  • ✓Validation schemas
  • ✓Legacy support
Full XML Documentation →

Why Convert JSON to XML?

Use XML when working with legacy systems, SOAP APIs, or when you need rich metadata and validation schemas.

JSON to XML: Frequently Asked Questions

How do I convert JSON to XML?

Paste your JSON into the editor on json2toon.co. The tool detects the input and produces XML instantly, then you copy the result. Conversion runs entirely in your browser, so nothing is uploaded to a server.

Is the JSON to XML converter free?

Yes. Converting JSON to XML on json2toon.co is free with no account, signup, or usage limit. A free public API is also available for automated, programmatic conversion.

Why convert JSON to XML?

XML is required for legacy systems, SOAP APIs, and certain document formats.

What should I watch out for when converting JSON to XML?

The orders array becomes repeated <orders> elements and the items array becomes repeated <items> elements. Rename array keys to singular nouns before converting if you want <order> and <item> tags.

Is my data safe when I convert JSON to XML?

Yes. The JSON to XML conversion happens client-side in your browser. Your source data stays on your device and is never sent to or stored on a server, which makes it safe for private or sensitive payloads.