Home/Dev Tools/JSON to XML Converter

JSON to XML Converter

Convert

Convert JSON to well-formed XML with custom root element and indentation.

Elements
Root
Item
Indent
Options
Input
Loading editor…
Output
Loading editor…
✨ AI Code Explanation
Mode

JSON to XML Converter — Free Online Tool

Convert any JSON object or array to well-formed XML instantly — no signup, no server round-trip. Customize root and item element names, pick your indentation, and optionally add an XML declaration. All processing happens entirely in your browser.

How to Convert JSON to XML

  1. Paste your JSON into the Input pane, click Upload, or load from a URL with the Load JSON from URL bar.
  2. Click Convert — the XML appears instantly in the Output pane. Or enable Live to auto-convert as you type.
  3. Set a custom Root element name (default: root) and Item name for array elements (default: item).
  4. Choose Indent: 2 spaces, 4 spaces, or tabs. Enable Compact for single-line output.
  5. Toggle Declaration to add <?xml version="1.0" encoding="UTF-8"?> at the top.
  6. Click Copy to copy the XML, or Download to save as output.xml.

JSON to XML Mapping Rules

  • Object keys → XML element names. Characters that are invalid in XML names are replaced with _.
  • Arrays → repeated child elements using the Item name you specify.
  • Primitives (strings, numbers, booleans) → text content of the element.
  • null values → self-closing element with a nil="true" attribute.
  • Special characters (& < > " ') → automatically XML-escaped.
  • Numeric or reserved keys → prefixed with _ to produce valid XML element names.

Live Mode and URL Loading

Enable Live mode to see the XML output update automatically as you edit the JSON — no need to click Convert. Paste a public JSON API endpoint into the Load from URL bar and click Load to fetch and convert remote JSON in one step. Works with any CORS-enabled endpoint.

Compact vs. Pretty Output

By default, JSON to XML formats the output with human-readable indentation. Toggle Compact to produce a single-line XML string — ideal for embedding in configuration files, HTTP payloads, or scripts where whitespace adds unnecessary bytes.

When Should You Use XML Instead of JSON?

  • SOAP web services — SOAP envelopes are XML by spec.
  • Legacy enterprise systems — many ERP and ESB platforms only consume XML.
  • Configuration files — Maven (pom.xml), Spring, Android manifests.
  • Document-centric data — XML supports mixed content, namespaces, and attributes that JSON cannot express.
  • RSS / Atom feeds — web syndication formats are XML-based.

Tips & Tricks

  • Root element name — defaults to <root>. Set a custom name for semantic clarity (e.g. <orders> for an order list).
  • Array element naming — JSON arrays don't have natural element names. Set Array item name to give each item a meaningful tag (e.g. <order>).
  • XML attributes vs elements — JSON has no distinction between attributes and elements. This converter outputs everything as elements; transform with XSLT if attributes are needed.
  • Preserve types via xsi:type — XML treats all values as strings unless typed. Add type annotations downstream if your consumer requires them.
  • Pretty-print for readability — enable Indent for human-readable XML; disable for the smallest possible output.

Related Tools

  • JSON Formatter — Format the source JSON before converting.
  • JSON Validator — Verify the source JSON parses cleanly first.
  • JSON to YAML — Modern alternative to XML for human-edited configs.
  • JSON to CSV — Convert to spreadsheet-compatible format.
  • HTML Formatter — XML is a relative of HTML; format markup output if needed.

Is My JSON Sent to a Server?

No. Every conversion runs locally in your browser using JavaScript. Your JSON data is never uploaded anywhere. The optional URL fetch loads the remote file directly into your browser — the data still never passes through our servers.