ToolHub

JSON to XML Converter

Convert JSON to XML and XML back to JSON

JSONXML

Convert JSON to XML and XML back to JSON. Repeated XML elements become JSON arrays. Conversion runs entirely in your browser — your data is never uploaded.

Overview

What this converter does

Convert JSON to XML and XML back to JSON, in both directions, with validation and clear error messages. Repeated XML elements become JSON arrays. It runs entirely in your browser using the built-in JSON and XML parsers, so your data is never uploaded.

Two data formats

JSON vs XML

Both store structured data, but they have different strengths:

JSONXML
ReadabilityCompact, easy to scanVerbose
Data typesStrings, numbers, booleans, null, arraysEverything is text
Native toJavaScript / web APIsEnterprise, documents, config
CommentsNot supportedSupported
AttributesNo (keys only)Yes
Best forWeb APIs, configsDocuments, legacy systems, SOAP

Most modern web APIs use JSON because it's lighter and maps directly to JavaScript objects. XML remains common in enterprise software, document formats (like DOCX and SVG), RSS feeds, and older SOAP web services.

The rules

How the conversion works

JSON to XML

Each key becomes a tag and its value becomes the tag's content. Nested objects become nested elements. An array becomes repeated elements with the same tag name. The whole thing is wrapped in a single root element, since XML requires exactly one.

XML to JSON

Each element becomes a key. When several sibling elements share a tag name, they're collected into a JSON array. An element with only text becomes a string value; an element with children becomes a nested object.

See it in action

A worked example

This JSON:

{ "person": { "name": "Ada", "skills": ["math", "code"] } }

becomes this XML:

<root><person><name>Ada</name><skills>math</skills><skills>code</skills></person></root>

Notice the array skills became two repeated <skills> elements — and converting back turns them into an array again.

Behind the scenes

Privacy and how it runs

Runs in your browser

Conversion uses the browser's native JSON and XML parsers. Your data never leaves your device, so it's safe for confidential payloads.

Common questions

How do I convert JSON to XML?

Paste valid JSON in JSON-to-XML mode. The tool builds an equivalent XML document instantly, which you can copy with one click. Invalid JSON is flagged with the parse error.

How are arrays handled?

A JSON array becomes repeated XML elements with the same tag name. Going the other way, repeated sibling elements become a JSON array. This is the standard convention for representing lists across the two formats.

Why does XML need a single root element?

The XML specification requires exactly one top-level (root) element that contains everything else. That's why the converter wraps JSON data in a root element. If your XML has multiple top-level elements, it's invalid and won't parse.

Does it handle XML attributes?

The converter focuses on element structure and text content, which covers most data-exchange needs. Attributes (values inside the opening tag) are a more specialized XML feature; heavily attribute-based XML may need a dedicated parser.

Why am I getting an "invalid XML" error?

Usually an unclosed or mismatched tag, or more than one root element. Check that every <tag> has a matching </tag> and that there's a single wrapping element.

Related tools

Quick steps

1

Pick a direction

JSON to XML, or XML to JSON. Tap the swap button to flip and reuse the output as the new input.

2

Paste your data

Drop in valid JSON or XML. Errors are flagged with a clear message so you can fix the syntax.

3

Copy the result

The converted output appears instantly. Copy it with one click.

Frequently asked questions

How do I convert JSON to XML?

Paste valid JSON in JSON-to-XML mode and the tool builds an equivalent XML document, wrapping the data in a root element and turning each key into a tag. Arrays become repeated elements with the same tag name.

How does XML to JSON handle repeated tags?

When an XML element contains several children with the same tag name, they're collected into a JSON array. A single child becomes a plain value, matching how most XML-to-JSON conversions work.

What's the difference between JSON and XML?

Both store structured data. JSON is lighter, easier to read, and native to JavaScript, which is why most modern web APIs use it. XML is more verbose but supports attributes, namespaces, and schemas, and is still common in enterprise systems, config files, and document formats.

Does this preserve XML attributes?

This converter focuses on element structure and text content, which covers the vast majority of data-exchange use cases. XML attributes (values inside the tag itself) are a more specialized feature; for attribute-heavy XML, a dedicated parser may be needed.

Why am I getting an invalid XML error?

The most common causes are unclosed tags, mismatched tag names, or a missing single root element (XML requires exactly one top-level element). Check that every opening tag has a matching closing tag.

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser using the built-in JSON and XML parsers. Your data never leaves your device, so it's safe for confidential payloads.