Skip to main content

JSON to XML Converter

Convert JSON into clean XML — object keys become element tags, arrays repeat their key as sibling elements, and every value is XML-escaped. Configure the root and array-item element names, pretty-print or minify, choose how nulls are handled, and toggle the XML declaration. Runs entirely in your browser.

Input

Options

Name of the single XML element that wraps the whole document.

Used only for keyless array items — a top-level array root or an array nested inside an array. Arrays under a key repeat that key instead.

How JSON null values are rendered.

Output

XML output
 
Was this helpful?

Guides

Turn any JSON object or array into well-formed XML in one step. Paste your JSON, tweak a couple of options, and copy or download the result. The converter maps JSON structures to XML using the conventions most parsers expect, escapes every value so your output is always valid, and never sends your data anywhere.

What it does

The tool walks your parsed JSON and builds an XML string directly:

  • Object keys become element tags. {"name": "Acme"} becomes <name>Acme</name>.
  • Arrays repeat their key as sibling elements. {"tag": [1, 2]} becomes <tag>1</tag><tag>2</tag> — the standard way to represent a repeated element in XML, rather than inventing numbered wrapper tags.
  • Primitives become text content. Strings, numbers, and booleans are placed inside their element and XML-escaped (&, <, >, ", and ').
  • The whole document is wrapped in a single root element (default root) so the output is always well-formed.

How to use it

  1. Paste or type your JSON into the input box (or click Try an example).
  2. Set the root element name — the single tag that wraps everything.
  3. Set the array item element name — used only when there is no key to repeat (a top-level array, or an array nested directly inside another array).
  4. Choose indentation: 2 spaces, 4 spaces, tab, or minified (single line).
  5. Pick how null values are rendered and whether to include the XML declaration.
  6. Copy the XML or download it as a .xml file.

The output updates automatically as you type.

How are invalid element names handled?

XML element names can only contain letters, digits, underscores, dots, and hyphens, and must begin with a letter or underscore. Any other character in a JSON key is replaced with an underscore, and a name that starts with a digit, hyphen, or dot is prefixed with an underscore — so "1st" becomes <_1st> and "first name" becomes <first_name>. An empty key becomes <_>.

How are null values handled?

You choose. Empty element renders null as a self-closing <key/>. Omit drops the element entirely. xsi:nil renders <key xsi:nil="true"/> and adds the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" namespace to the root element, which is the schema-aware way to mark a value as explicitly null.

What happens with a top-level array?

A single array at the top level has no key to repeat, so each item is wrapped in the array item element name (default item) inside the root. Nested arrays inside arrays are handled the same way.

Does it validate my JSON?

Yes. If the input isn't valid JSON, you'll see an inline error explaining the parse problem before any XML is produced. Fix the JSON and the output regenerates instantly.

Can I convert XML back to JSON?

This tool is one-way (JSON to XML). XML-to-JSON is a separate conversion because XML carries information — attributes, mixed content, namespaces — that has no single canonical JSON form.

Privacy

Everything runs entirely in your browser. Your JSON is parsed and converted locally in JavaScript — it is never uploaded to a server, logged, or stored. You can even use the tool offline once the page has loaded, which makes it safe for converting configuration, credentials, or any other sensitive data.

jsonxmlconverterdeveloper

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.