Skip to main content

Data & Format / JSON Tools

JSON to XML

JSON to XML converts in both directions and documents exactly how arrays, attributes and mixed content are mapped, because the JSON to XML transform has no standard and every library picks different conventions.

Sponsored

This space is reserved for a sponsor.

Sponsored

This space is reserved for a sponsor.

How to use

  1. 1

    Paste JSON or XML

    The tool detects the direction from the input, so paste either format into the box and convert without choosing a mode.

  2. 2

    Convert

    The other format appears on the right. The conversion runs in your browser, so neither document is uploaded.

  3. 3

    Read the mapping it used

    The output includes the rule applied for arrays, such as repeated tags versus indexed tags, and for attributes, shown with an at sign, so you can read the result with confidence.

  4. 4

    Handle attributes

    XML attributes map to keys prefixed with an at sign, so an element user id="7" becomes an object with an @id member. Use that convention on the JSON side when you need attributes in the output.

  5. 5

    Copy the result

    Copy the converted text to your clipboard. The text never leaves your browser and nothing you paste is sent to any server.

Key facts

  • No standardThere is no standard mapping between JSON and XML; each library invents its own conventions for arrays, attributes and text nodes.Source:This tool
  • ArraysThe most divergent case is arrays: repeated tags, indexed tags and wrapping each produce different but valid output.Source:This tool
  • AttributesXML attributes are commonly represented in JSON with an at sign prefix, a convention shared by several libraries rather than a standard.Source:This tool
  • JSON modelJSON has objects, arrays, strings, numbers, booleans and null; it has no attributes, text nodes or namespaces.Source:RFC 8259
  • PrivacyConversion runs entirely client side; no document is transmitted to any server.Source:This tool

Frequently asked questions

Does this tool upload my JSON or XML?

No. The conversion runs entirely in your browser and no network request leaves your machine. These documents often carry integration payloads, credentials or internal schemas, and any service that round-trips your text through a server has written it into that server logs. Verify it yourself: open the developer tools, watch the network panel, paste a document and convert it; no request appears. The only browser interface the page touches is the clipboard, and only when you press Copy.

How are arrays mapped between JSON and XML?

Arrays are the single most divergent case, because there is no standard. This tool repeats the element tag for each item by default, so a JSON array of two strings becomes two elements with the same name. Other libraries instead append an index and emit item_0 and item_1, or wrap the array in a parent element, or collapse a single-item array to a bare element. None of these is wrong; they are simply different conventions. Because consumers often expect a specific one, the tool states the rule it used so the output matches what the reader expects instead of surprising it.

How are XML attributes represented in JSON?

Attributes are represented with an at sign prefix: the element user id="7" name="amy" maps to the JSON object with an @id and an @name member. This is a convention used by several popular converters, not a standard, so a different library might instead nest attributes under a reserved key such as attributes. If you are exchanging JSON with a specific system, confirm which convention it uses; mismatches here are the most common cause of apparently broken JSON to XML interop.

Why did my structure change when I converted back?

Because the two formats are not symmetric. XML has attributes, text nodes, namespaces and mixed content; JSON has none of those. A JSON to XML to JSON round trip normalizes these differences, so an attribute may become a regular member, a text node may be merged into a value, and namespace prefixes may be flattened into the element name. The result is semantically close but not byte identical to the input, and for some documents information such as namespace details is genuinely lost. The tool documents the mapping so you can predict and verify the change.

Does it handle XML namespaces?

Namespaces are preserved as part of the element and attribute names where the parser supports them, but the JSON representation of a namespaced name is library specific: some keep the prefix as written, others expand to the full URI. Because there is no standard JSON encoding of an XML namespace, the safest approach is to agree the exact form with whatever system consumes the output, or to strip namespaces before converting if the downstream reader does not use them. The tool surfaces the form it produced so you can check it against the consumer expectation.

Related tools

Sponsored

This space is reserved for a sponsor.