Skip to content

JSON to XML

Create clean XML from a documented JSON mapping for elements, attributes and text.

JSON → XML86 characters
Paste configuration text. The live preview stays inert and is limited for responsiveness.
XML previewReady
<?xml version="1.0" encoding="UTF-8"?>
<profile id="a1">
  <name>Ada</name>
  <tag>math</tag>
  <tag>code</tag>
</profile>
Processed on your device

How it works & useful details

XML mapping

Provide one top-level property for the root element. In an object value, keys prefixed with @ become scalar attributes, #text becomes scalar text, other keys become child elements, and arrays repeat a named child element.

Names use the portable subset of XML names: letters/underscore first, then letters, digits, underscore, dot or hyphen. Null becomes an empty element.

Private, bounded processing

This workspace parses text only in your browser. It never opens links, requests external entities, runs pasted configuration, or saves your document. Input is limited to 500,000 characters; conversion output is limited to 1,000,000 characters.

About this tool

JSON to XML creates clean XML from JSON using a documented, predictable mapping for elements, attributes, and text content. It is designed for producing configuration or data documents where you want to control the output shape.

Because the mapping is explicit rather than automatic, the same JSON always produces the same XML. The conversion is local, does not load external entities, and reports values it cannot represent.

How to use it

  1. Paste the JSON document.
  2. Choose how keys map to elements and attributes following the documented rules.
  3. Convert and review the generated XML, including any warnings.
  4. Copy or download the XML for use in your project.

Worked example

{ "profile": { "@id": "a1", "name": "Ada", "tag": ["math", "code"] } }

produces

<?xml version="1.0" encoding="UTF-8"?>
<profile id="a1">
  <name>Ada</name>
  <tag>math</tag>
  <tag>code</tag>
</profile>

The single top-level key names the root element. @id becomes an attribute, and the tag array becomes a repeated <tag> element. XML has no arrays, so repetition is how lists are expressed.

The mapping conventions

  • Keys starting with @ become attributes, which must be simple values, not objects or arrays.
  • #text sets an element's text content next to its attributes, as in {"price": {"@currency": "EUR", "#text": "19.99"}}, which gives <price currency="EUR">19.99</price>.
  • Arrays repeat the element named by their key.
  • null becomes an empty element.

These are the same conventions XML to JSON produces, so a document can make a round trip. Element names must be valid XML names, starting with a letter or underscore, so JSON keys with spaces or leading digits are rejected rather than mangled. Special characters in text and attributes are escaped automatically.

Frequently asked questions

How are arrays represented?

Repeated children are emitted for each array item, using the documented naming rules so the structure remains valid XML.

Can I control attribute keys?

Yes. The mapping documents the reserved key pattern used to mark attributes, so you can shape the output deliberately.

What is the limit?

Up to 500,000 characters of JSON input; generated XML is bounded as well.

Why must there be exactly one top-level key?

An XML document has exactly one root element. The single top-level property provides its name. Wrap multiple values in an object if needed.