JSON/XML

JSON to XML Converter

Map strict JSON to XML with explicit arrays, root attributes and text rules

Data Format
🔒 100% client-side — your data never leaves this page
Maintained by Evan•Updated: September 30, 2026

Convert a defined record mapping locally. Review the mapping rules below before using the output; this does not preserve every XML/JSON data model. Input stays in this page; drafts are not stored. Limits: 1 MiB input, 4 MiB output, 20,000 XML nodes including attributes, 64 element levels. Textareas normalize pasted line endings; upload UTF-8 to retain original CSV carriage returns.

JSON

Object keys create children; @name and #text map to the current element, including the root. Attribute/#text values must be scalar; #text cannot coexist with child keys. Arrays repeat their key; top-level arrays use the item name. Empty arrays produce no items; null, empty text and empty objects become empty elements, so this is not a typed round trip. Nested arrays, namespaces, duplicate keys and unsafe numeric tokens are rejected. Quote exact numbers.

About this tool

JSON to XML uses an explicit namespace-free mapping. Object keys create child elements; @name creates an attribute on the current element, including the root, and #text supplies its scalar text. Attribute and #text values must be string, number, boolean or null. #text cannot coexist with child-element keys because this mapping does not represent ordered mixed content. An array repeats its key; a top-level array uses the configured item name. Empty arrays produce no items; null, empty strings and empty objects become empty elements, so type distinctions and full round trips are not retained. Nested arrays require named objects instead. Duplicate decoded keys, unsafe integer/decimal tokens, negative zero, overflow, underflow, namespaces and invalid names are rejected before output. Accepted numbers are normalized to JavaScript’s exact round-trip representation; quote identifiers and exact original number spellings. Legal Unicode names and prototype-like keys are preserved. Input is limited to 1 MiB, output to 4 MiB, XML to 20,000 nodes including attributes and 64 element levels. UTF-8 uploads use strict decoding; pasted text follows the browser textarea line-ending rules. Processing runs locally, and draft input is not saved.

Scenario Recipes

01

Draft a deliberate XML mapping from a JSON fixture

Goal: Resolve numeric precision and empty-value semantics before integration.

  1. Quote exact identifiers and decimals, and remove duplicate decoded keys in the source. Choose the XML root and top-level item name.
  2. Use @name attributes and scalar #text only where they do not conflict with child-element content. Use named objects for additional array levels.
  3. Generate and inspect repeated elements, empty values and field order, then validate the complete downloaded XML against the receiver’s schema separately.

Result: A generic XML mapping with its type and structure limits exposed.

Failure Clinic (Common Pitfalls)

A long JSON numeric ID changed digits before XML was written

Cause: Ordinary JSON.parse already rounds numeric tokens beyond its precise range.

Fix: Use a JSON string from the original exact data. This tool rejects numeric tokens that cannot round-trip safely.

Empty values and arrays do not reconstruct their original types

Cause: XML element text has no automatic JSON type or array marker.

Fix: Review the documented null/empty/array mapping. Use a schema-specific serializer when those distinctions must survive a reverse conversion.

Production Snippets

Root attributes and scalar text use the same rule as nested objects

json

{"@id":"001","#text":"  A & B  "}

Root: record
<record id="001">  A &amp; B  </record>

Frequently Asked Questions

Do @id and #text work at the root?

Yes. They map to the current element at every object level. Attribute and #text values must be scalar; #text may coexist with attributes but not child-element keys.

How do arrays and empty values map?

Arrays repeat the property name, or the configured item name at the top level. Empty arrays emit no items. Null, empty text and empty objects become empty elements; nested arrays are rejected.

Why is a syntactically valid JSON number rejected?

The original numeric token must round-trip exactly to a finite JavaScript number, and integral values must be safe integers. Negative zero, overflow and underflow are also rejected. Quote exact numbers or identifiers when those rules do not fit.

Does the result preserve namespaces, types or schemas?

No. This is a namespace-free generic mapping, not a typed reverse mapping or XSD validator. It rejects ambiguous structures rather than inventing namespace or mixed-content semantics.

Keep browsing