JSON to XML Converter
Turn JSON arrays or objects into well-formed XML. Paste or upload JSON, customize element names, indentation, and attributes, and copy or download the result — all in your browser.
100% Client-Side Processing
Your JSON is parsed and converted entirely in your browser. Nothing is uploaded to a server.
Options
Table of Contents
What is a JSON to XML Converter?
A JSON to XML converter takes structured JSON data — an array of objects, or a single object — and rewrites it as XML (Extensible Markup Language), the tag-based data format used by legacy enterprise APIs, SOAP services, RSS/Atom feeds, configuration files, and many document-processing and B2B data-exchange systems that predate or never adopted JSON.
The converter walks the JSON structure and maps each key to an XML element: object keys become child elements, arrays repeat the same element once per item, and primitive values become element text content — producing well-formed, indented XML you can paste directly into an XML-consuming system.
How it Works
- Add your JSON: Paste JSON directly into the editor, or upload a .json file.
- Choose your options: Set a root element name, an element name for top-level array items, an indentation style, whether to include the XML declaration, and whether @-prefixed keys should become XML attributes.
- Read the result instantly: The tool parses your JSON in your browser and shows the converted XML as you type, along with line and character counts.
- Copy or download: Copy the XML to your clipboard or download it as an .xml file.
Features
- Paste JSON or upload a .json file
- Instant, live conversion as you type — no button to click
- Works with a single JSON object or an array of objects
- Customizable root element and array-item element names
- Arrays convert to repeated sibling elements, not indexed wrapper tags
- @-prefixed keys convert to XML attributes instead of child elements
- Configurable indentation (2, 4, 8 spaces, or tab)
- Optional XML declaration (<?xml version="1.0" encoding="UTF-8"?>)
- Automatic escaping of &, <, >, and " in text and attribute values
- Invalid XML element names are automatically sanitized
- Live line and character counts
- 100% client-side processing for privacy
Best Practices
- Give the root element a meaningful name: the default "root" works, but a name matching your schema (e.g. "customers", "order") makes the output easier to read and validate downstream.
- Use @-prefixed keys for values that belong as attributes: if your JSON already models attribute-like fields with an "@" prefix (a common convention from XML-to-JSON round-tripping), turning on "Use @-prefixed keys as XML attributes" produces XML matching typical attribute usage instead of an extra layer of child elements.
- Keep object keys consistent with XML naming rules: keys with spaces, leading digits, or special characters get automatically sanitized to valid XML element names, so keeping your JSON keys close to valid identifiers avoids surprises in the output.
- Check how empty arrays and nulls are represented: both produce a self-closing element (e.g. <tags/>) rather than being omitted, so downstream XML parsers relying on the element's presence still find it.
- Validate against your target schema: this tool produces well-formed XML but has no awareness of a specific DTD or XSD — run the output through your schema validator if the receiving system enforces one.
Troubleshooting
It says my JSON is invalid
Check for a trailing comma after the last item in an array or object, unquoted keys, single quotes instead of double quotes, or an unclosed bracket — these are the most common reasons JSON fails to parse.
An array produces repeated elements instead of one wrapping element
This is intentional: `"tags": ["a", "b"]` under a key produces `<tags>a</tags><tags>b</tags>` as siblings, which is the standard convention most JSON-to-XML tools use, rather than a `<tags><item>a</item><item>b</item></tags>` wrapper.
A key changed in the output, like my key becoming my_key or 2fa becoming _2fa
XML element names can't contain most special characters and can't start with a digit, so invalid keys are automatically sanitized (invalid characters replaced with underscores, a leading underscore added if the name starts with a digit) to keep the output well-formed.
Attributes didn't appear even though I have @-prefixed keys
Make sure "Use @-prefixed keys as XML attributes" is enabled — with it off, @-prefixed keys are treated as regular child elements like any other key.
Common Use Cases
- Integrating with legacy or SOAP-based APIs: many enterprise and government systems still expect XML request or import payloads — convert JSON from a modern source into the XML format they require.
- Generating RSS/Atom-style feeds: convert structured JSON content into an XML feed format for syndication.
- Producing configuration files: some build tools, CI systems, and legacy applications read configuration as XML rather than JSON.
- Migrating data between XML- and JSON-based systems: export from a JSON-native database or API and import into an XML-based document store or ETL pipeline.
- Testing XML-consuming code: quickly generate sample XML payloads from JSON test fixtures without hand-writing XML.
Frequently Asked Questions
Yes. A single object becomes the root element's children directly. A top-level array is wrapped in the root element, with one child element per item.
Nested objects become nested XML elements. Arrays produce one sibling element per item using the same tag name as the array's key, rather than a single wrapping element with indexed children.
Yes. Enable "Use @-prefixed keys as XML attributes" and prefix any key in your JSON with @ (e.g. "@id") to have it rendered as an attribute on its parent element instead of a child element.
Keys are automatically sanitized: characters that aren't valid in XML element names are replaced with underscores, and a leading underscore is added if the name would otherwise start with a digit.
No, it's optional and controlled by the "Include XML declaration" toggle. Many systems accept XML without it, but including <?xml version="1.0" encoding="UTF-8"?> is standard practice for standalone XML documents.
No. Everything happens locally in your browser, and nothing is uploaded or saved.
The converter runs in your browser's memory, so very large JSON files (tens of megabytes or more) may be slow or use a lot of memory depending on your device.