JSON ↔ XML Converter - Bidirectional JSON and XML Conversion
Developer Tools
Convert JSON to XML or XML to JSON in your browser. Open and download local files, map XML attributes, and format output without uploading data.
Open a local .json or .xml file, or drop one onto either pane. File contents stay in this browser; nothing is uploaded. Files over 10 MB may slow conversion.
How to use this tool
- Paste JSON into the JSON panel or open a local .json file, then click "JSON to XML".
- Paste XML into the XML panel or open a local .xml file, then click "XML to JSON".
- Choose the root name, indentation, XML attribute mapping, and declaration options as needed.
- Copy or download either pane. Files are read locally in your browser.
Conversion challenges
JSON and XML have different data models, which creates mapping challenges:
- Arrays: JSON has native arrays; XML represents them as repeated elements with the same tag name, losing explicit list semantics
- Attributes vs. elements: XML can attach metadata via attributes (
id="42"); JSON has no native attribute syntax, so this converter uses a selectable key prefix such as@_idto preserve the distinction. - Mixed content: XML elements can contain both text and child elements simultaneously; JSON objects cannot directly represent this
- Key order: JSON object keys have no guaranteed order; XML child element order is significant in many schemas
When to use each format
| Use case | Recommended format |
|---|---|
| REST API data exchange | JSON |
| SOAP web services | XML |
| Document-centric data (books, articles) | XML |
| Configuration files | JSON or YAML |
| Office / spreadsheet interop (OOXML) | XML |
| Modern browser / mobile apps | JSON |
Namespace handling
XML namespaces (e.g. xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/") have
no JSON equivalent. This tool's basic converter drops namespace declarations on XML->JSON
conversion and does not add them on JSON->XML. For SOAP envelopes, XBRL, or other
namespace-heavy XML formats, use a server-side XSLT transform or a library like
fast-xml-parser (Node.js) with namespace support enabled.
Conversion Rules
JSON objects become XML elements with child elements for each key. Arrays are serialized as
repeated elements sharing the same tag name. Primitive values (strings, numbers, booleans)
become text nodes, with XML special characters properly escaped. The root element defaults to
root, and you can select two-space, four-space, or tab indentation and choose
whether to include the XML declaration. Invalid XML-name characters are replaced with
underscores.
XML attributes use the @_ prefix in JSON by default: an XML attribute such as
id="42" becomes "@_id": "42". You can select @,
_, or ignore attributes for compatibility with element-only data. Text mixed with
child elements is represented by #text, although ordering several separate text
segments among child elements cannot be preserved by this simple JSON mapping.
Opening and saving files
Open a local .json or .xml file with the Open button, or drop it on either
editor. The browser reads the file locally; it is not uploaded. Download saves the text currently
shown in either pane. Files over 10 MB remain usable, but large documents may make parsing and conversion
slower.
Limitations
The converter does not preserve namespace declarations, processing instructions, or CDATA boundaries. It also coerces simple XML text values such as numbers and booleans into JSON values, so identifiers with leading zeroes can change. For namespace-heavy schemas or exact mixed-content fidelity, use a schema-aware XML library and review its output.
Frequently asked questions
How are JSON arrays converted to XML?
Each array element is output as a repeated element with the same tag name. For example, ["a","b"] under key "item" becomes <item>a</item><item>b</item>.
Are XML attributes supported?
Yes. The default @_ prefix maps an XML attribute such as id="42" to the JSON key "@_id" and maps that key back to an attribute. You can choose @, _, or Ignore attributes. Direct text in a mixed-content element is represented by #text; complex interleaved XML text cannot always round-trip exactly.
Are my files uploaded?
No. JSON and XML files are read with the browser File API, and conversion and downloads happen in this browser. The tool does not send file contents to a server.
Related tools
- XML FormatterUse XML Formatter to format, beautify, or minify XML online. Validates well-formedness,.
- JSON FormatterUse JSON Formatter to format, validate, and minify JSON instantly in your.
- JSON ↔ YAMLUse JSON ↔ YAML to convert JSON to YAML or YAML to JSON.
- JSON -> TSUse JSON -> TS to paste JSON and instantly generate TypeScript interfaces with.