JSON tools

JSON to XMLchoose the structure your receiver expects

Try the example’s attribute, text field, empty array and null. Adjust the mapping before exporting.

JSON to XML

XML to JSON

JSON input

Processed in this browser. Your input is not uploaded or stored.

XML result

Output options

Type preview

Result is out of date; export is disabled.

JSON to XML is useful when a service returns objects and lists but an integration accepts an XML document. The receiving system decides which names and namespaces belong in that document; conversion alone cannot discover its contract.

This converter keeps the chosen root around every input, even a single scalar. It exposes the mapping choices instead of treating one library’s conventions as a universal format standard.

Why use JSON to XML here?

Keep empty collections visible

JSON to XML places a list inside its named container and writes each member as an item element. An empty list keeps its container. A nested list keeps another level, so changing the item name never removes an array boundary.

An array enters a container with two child items, while an empty array keeps a separate empty container.

Separate attributes from content

A prefixed field such as @id becomes an attribute; #text supplies the element’s text. An object can combine those two roles. The converter refuses text mixed with child elements because JSON member order cannot express arbitrary mixed content.

A data object sends one value to a tag attribute and another value to the text between its tags.

Set the receiving document’s conventions

01

Name the wrapper deliberately

The root name is always an added wrapper. A root object with one property still keeps that property below the wrapper. Arrays use the item name at every level; check that this layout matches the consuming system.

02

Check special fields before changing them

Mapping starts enabled with @ and #text. Both markers can be changed. Disabling mapping makes all keys element names, so a remaining @id or #text fails name validation rather than disappearing.

03

Use manual mode for several edits

Auto-convert waits 350 milliseconds. Turn it off to adjust several options, then use Convert or Ctrl/Cmd+Enter. Editing input or an option disables export immediately; the preview lists the first 500 nodes in batches of 50.

A document with explicit structural choices

Root, arrays and namespaces

Choose any valid XML 1.0 local name for the root and array items. A nonempty default namespace URI is declared once at the root and applies to all elements. Unprefixed attributes remain outside that namespace.

Null has its own marker

The default writes xsi:nil="true" and declares the xsi namespace automatically. Reject mode stops at the first null. Empty strings, empty objects and empty arrays still produce present, empty elements; they are never omitted.

Text values are preserved

Integer and decimal tokens are emitted from a lossless JSON syntax tree: 9007199254740993, -0 and 1e999 stay as written. XML special characters are escaped. Attribute tabs and line breaks use character references to survive XML normalization.

Checked before export

The output is parsed as XML 1.0 with namespace checks, then element names, attribute values and text are compared against the mapped tree. Choose two spaces, four spaces or compact output, with an optional UTF-8 declaration.

Where the mapping stops

XML does not retain every JSON type
Numbers and booleans become text without JSON type annotations. Empty array, empty object and empty string can have identical XML. Keeping every node does not make the reverse conversion unambiguous; no lossless round-trip guarantee is made.
Names are never silently repaired
Empty keys, spaces, leading digits and other invalid XML names stop conversion with a JSON Pointer. The converter does not replace characters with underscores, sort keys, repair JSON, accept comments or keep the last duplicate key.
Attribute and text fields need scalar values
Mapped attributes and the text field accept only non-null strings, numbers and booleans. Arrays, objects and null there are errors. A text field alongside child elements is also rejected, including an empty text field.
Namespace scope is intentionally limited
Use the default namespace option and, if needed, @xml:lang. Other colon names, xml:space, user xmlns declarations and xsi overrides are rejected. XML and XMLNS reserved URIs cannot be default namespaces. There is no XSD, DTD or SOAP contract validation.
Bounded text conversion
Limits are 500,000 input characters, depth 100, 50,000 nodes and 2,000,000 output characters. XML 1.0 forbidden controls and unpaired surrogates are errors. There is no URL loading, file import, batch archive, CDATA generation or reverse conversion on this page.

JSON to XML questions

How do arrays map into XML?

Each array is a container whose children use your item name. A property called orders becomes an orders container, and an empty orders list remains an empty element. This differs from repeating the property name directly; check your schema before using the result.

When is CDATA useful?

CDATA is useful when a reader prefers literal markup inside text, but it is not needed to preserve the text value. This JSON to XML converter uses entity escaping and does not generate CDATA sections or interpret strings as XML fragments.

How do elements differ from attributes?

An element has its own place in the tree; an attribute belongs to an element’s opening tag. Use @id for an attribute and #text for body text with the default mapping. The tool does not automatically turn every scalar into an attribute.

Can I validate the generated document against XSD?

This page checks well-formed XML and namespaces only. An XSD validator also needs the receiving system’s schema, including whether an element is nillable. A successful conversion does not establish those business requirements.

What happens to JSON keys that are invalid XML names?

Conversion stops and reports the path. Rename the field yourself or change the root or item name option. JSON to XML online should not hide a key collision by normalizing two different names into the same XML name.

Does your XML document expose a mapping edge case?

Prepare your next document

Use JSON to XML to inspect the sample, then set the root and namespace required by your integration.