ToolConvoyToolConvoyv2.6
DATA

JSON to XML — Convert JSON to XML Markup

Convert JSON data to XML markup format. Configurable root element, attribute-vs-child heuristics, pretty-print — in your browser, no upload.

● LOCAL · ZERO-COPY PIPELINE0 network requests since page load

XML and JSON have been the two poles of data serialization for the last two decades. JSON won the web: it is the native format of the browser, the default for REST APIs, and the input to every modern framework. XML won the enterprise: it is the format of SOAP, of configuration files for legacy systems, of document storage for regulated industries, and of data interchange formats where a formal schema is a legal requirement. Converting between them is a bridge between two eras, and the conversion always involves decisions that are more about convention than about data.

The two conventions that matter most: the @ prefix for XML attributes and the handling of JSON arrays as repeated elements. The @attr convention is a de facto standard — it is not part of any specification but it is so widely used that every JSON-to-XML converter supports it. A JSON key like @type in a JSON object becomes type="..." in the parent XML element. Arrays become repeated sibling elements with the same tag name, which is the only natural mapping: JSON’s ordered list of values has no equivalent in XML’s unordered element model except a parent element that repeats. Both conventions are configurable in the output options.

The most common downstream step after generating XML is to validate it against an XML Schema (XSD) to guarantee it conforms to the expected structure. The companion json-to-xsd tool on this site can generate that schema from the same JSON. If the destination is a SOAP endpoint or an XML-RPC call, the generated XML is the payload body. If the destination is a document store or an archive, the pretty-printed XML is human-readable and diff-friendly.

How to use

  1. Paste your JSON

    Drop a JSON object or paste a JSON string. The converter walks the structure and emits an XML document with a configurable root element name.

  2. Choose XML conventions

    Set the root element name, choose pretty-print indentation (2 or 4 spaces), and toggle the attribute heuristics: JSON keys starting with `@` become XML attributes instead of child elements.

  3. Copy or download the XML

    Copy the formatted XML to your clipboard or download as an .xml file. The output is valid XML 1.0 and opens in any browser or XML-aware editor.

Frequently asked

How are JSON keys converted to XML element names?

JSON keys become XML element names directly. Keys that start with a digit, contain spaces, or include characters illegal in XML element names are automatically prefixed with an underscore. The `@attr` convention (a key starting with @) becomes an XML attribute on the parent element.

What happens to JSON arrays?

JSON arrays become repeated XML elements. A JSON `items: [{name: 'a'}, {name: 'b'}]` becomes `<items><name>a</name></items><items><name>b</name></items>`. The wrapping element takes the JSON key name and the inner structure repeats per array element.

How are JSON objects with mixed content handled?

A JSON object where some keys are primitives and others are nested objects becomes an XML element with both child elements (for the nested objects) and text content (for the primitives). Mixed content is valid XML but unusual — most schemas expect either text or children, not both.

Does it produce XML namespaces?

No. The output is unnamespaced XML. Add `xmlns` attributes and namespace prefixes by hand if your target schema requires them. The `json-to-xsd` tool on this site can generate an XML Schema with namespace declarations from the same JSON.

Can I control the indentation and formatting?

Yes. Toggle between 2-space and 4-space indentation. Enable 'compact' mode for minimal whitespace (suitable for machine-to-machine exchange). The pretty-print default is 2-space indentation.

Limitations

  • No XML declaration controlThe output includes `<?xml version="1.0" encoding="UTF-8"?>` by default. If your consumer expects a standalone or ISO-8859-1 declaration, edit the first line by hand.
  • No CDATA sectionsString values are emitted as XML text content, not CDATA sections. If your JSON contains HTML or XML fragments that must be wrapped in CDATA, add the `<![CDATA[...]]>` wrapper by hand after generation.
  • Attribute ordering is not preservedJSON objects have no guaranteed key order in the specification, so XML attributes derived from @-prefixed keys may appear in any order. For schemas that mandate a specific attribute order, sort by hand.

Platform notes

macOS
The generated XML opens in Safari, Chrome, and any XML-aware editor. Use the browser tool for one-off conversion of a JSON config to XML for a legacy system that still expects SOAP or XML-RPC.
Windows
The generated XML opens in Edge and any XML editor. Use it for one-off conversion where a JSON API response needs to be fed into an XML-based downstream system.
Linux
For command-line work, `xmlstarlet` and `yq` can convert between formats. The browser tool is the right pick for one-off conversion where a shell environment is not available.
Web
Runs entirely client-side. The conversion takes milliseconds.

Related tools