XML to JSON and JSON to XML Converter

Convert XML to JSON and JSON to XML in your browser. Attributes become @ keys, element text becomes #text, numbers and true/false can be converted, and invalid XML is reported clearly.

  • Free
  • No upload
  • No signup
  • Works offline

Your files never leave your device

How to use XML ⇄ JSON

  1. 1Choose the direction

    Select XML → JSON or JSON → XML.

  2. 2Paste or open your data

    Paste XML or JSON into Input, or open a file.

  3. 3Set options

    Tick Convert numbers and true/false to get typed JSON values. For JSON → XML, set the Root element name.

  4. 4Copy or download

    The Output updates instantly. Copy it or download it.

Bridge old and new data formats

XML is still everywhere: RSS and Atom feeds, sitemaps, SOAP APIs, Office files, bank exports, e-invoicing, Android layouts and many enterprise systems. Modern code and APIs prefer JSON. This XML to JSON converter translates between them in both directions with predictable rules.

Conversion rules

XML has features JSON doesn’t – attributes, mixed text and repeated elements – so the tool uses a widely used convention:

  • Elements become keys.
  • Attributes become keys prefixed with @.
  • Text inside an element with attributes or children becomes #text; simple elements with only text become plain values.
  • Repeated elements with the same name become arrays.

Example:

<order id="1042">
  <item sku="A1">Notebook</item>
  <item sku="B7">Pen</item>
  <paid>true</paid>
</order>

becomes

{
  "order": {
    "@id": "1042",
    "item": [
      { "@sku": "A1", "#text": "Notebook" },
      { "@sku": "B7", "#text": "Pen" }
    ],
    "paid": true
  }
}

The status line reminds you: keys starting with @ become attributes; #text becomes element text.

Convert numbers and true/false

XML has no data types – everything is text. Tick Convert numbers and true/false to turn values like 1042 and true into JSON numbers and booleans. Leave it off when values such as IDs or postcodes have leading zeros you need to keep.

JSON → XML

Choose JSON → XML and paste JSON. The same rules apply in reverse: @ keys become attributes, #text becomes text and arrays become repeated elements. XML needs exactly one root element. If your JSON has a single top-level key, that key becomes the root; otherwise the output is wrapped in the element named in Root element (JSON → XML) (default root) – useful when the JSON is an array or has several top-level keys. Special characters such as & and < are escaped automatically.

Fixing invalid XML

If the input isn’t well-formed, the tool shows Invalid XML: with the parser’s message. Common causes:

  • A missing or misspelled closing tag (<Name>…</name> – XML is case-sensitive).
  • An unescaped & – write &amp;.
  • Text before the root element or two root elements.
  • A copy-paste that cut off the end of the document.

Round trips

Because the same conventions are used in both directions, you can convert XML to JSON, edit it in your code or editor, and convert it back. Comments, processing instructions and the original whitespace are not preserved, and the element order inside a parent may be grouped by name, so compare the result with the original if an exact layout matters – for example for files that are validated against a strict XSD schema.

Large documents

Feeds and exports of several megabytes convert in a moment on most devices. For very large files, paste only the part you need, or split the file first.

Common uses

  • Reading RSS feeds or sitemaps in JavaScript.
  • Converting SOAP or legacy API responses for a modern frontend.
  • Inspecting XML exports from accounting or e-commerce systems.
  • Generating XML config from JSON.
  • Converting product feeds between platforms.

Use CSV to JSON for spreadsheet data, Excel to CSV for workbooks, and Base64 Encode / Decode for embedded binary data, which is common inside XML.

Privacy

Everything runs in your browser using its built-in XML parser. Your data is not uploaded.

Frequently asked questions

How are XML attributes represented in JSON?

Attributes become keys starting with @, for example <item id="7"> becomes {"item": {"@id": "7"}}. Element text alongside attributes or children is stored under #text.

What happens to repeated elements?

Repeated child elements with the same name become a JSON array, so a list of <item> elements turns into "item": [ ... ].

Can I convert JSON back to XML?

Yes. Choose JSON → XML. Keys starting with @ become attributes and #text becomes element text. Set the Root element name to wrap the output.

Why does it say Invalid XML?

The XML isn't well-formed – often a missing closing tag, an unescaped & character or mismatched case. The error message tells you what the parser found.

Are namespaces supported?

Element and attribute names keep their prefixes, such as soap:Body, so namespaced XML converts predictably.

Is my data uploaded?

No. Conversion uses your browser's built-in XML parser.

Cookie settings

Choose which optional technologies may be used on this browser. Your choice is saved on this device only (in local storage) and is sent to Google using Consent Mode. Files you process are never uploaded, whatever you choose.

Remembers your theme and this consent choice, and lets the site work offline. Always on; nothing is shared.

Lets Google store and read cookies to serve, cap and measure ads, and receive ad-related data about your visit (ad_storage, ad_user_data). If off, Google may still show limited, non-personalised ads without cookies.

Lets ads be tailored to your interests (ad_personalization). Requires Advertising.

Allows privacy-friendly usage statistics (analytics_storage). We do not run analytics today; this stays off unless you allow it.