JSON to XML Converter
Turn a JSON object or array into well-formed, properly escaped XML — free, instant, and entirely in your browser.
Conversion happens locally in your browser. Nothing you paste is uploaded, logged, or stored.
How to Use the JSON to XML Converter
- Paste your JSON into the input box, or press "Load example" to start from a small feed-shaped document.
- Type the root element name you want. XML allows exactly one root, so every key in your JSON becomes a child of it.
- Choose 2-space or 4-space indentation for readable XML, or minified for one compact line, and leave "Add XML declaration" on if the consumer expects a <?xml ... ?> prolog.
- Click "Convert to XML". Objects become nested elements, arrays repeat their key as sibling tags, and an "@attributes" object becomes real XML attributes.
- Copy the result with "Copy result", or press "Clear" to reset the input, output, and any warnings.
What Is a JSON to XML Converter?
A JSON to XML converter rewrites a JSON document as an XML tree. Each object key becomes an element, nested objects become nested elements, and primitive values become the text inside a tag. You need it whenever a modern service produces JSON but the system on the other side speaks XML — SOAP endpoints, EDI and e-invoicing pipelines, RSS publishing, Android resources, sitemap generation, or an ERP that has not changed its import format since 2004.
Two details separate a usable conversion from a broken one. The first is arrays: JSON has them natively and XML does not, so an array has to be flattened into sibling elements that repeat the same tag name. The second is escaping — an unescaped ampersand or angle bracket makes the whole document unparseable, so text content escapes &, < and >, while attribute values also escape double quotes. This converter also checks every key against the XML naming rules and renames anything illegal (a leading digit, a space, a slash) to an underscore form, then tells you exactly what it changed instead of emitting XML that silently fails downstream.
Need the other direction? The XML to JSON converter reverses the process and understands the same @attributes convention, so documents round-trip cleanly. Before converting, it is worth tidying your input with the JSON formatter or catching a stray comma with the JSON validator.
Frequently Asked Questions (FAQ)
How do I convert JSON to XML online?
Paste your JSON, set a root element name, and click "Convert to XML". The XML is generated in your browser and shown immediately, ready to copy — no upload and no account needed.
How are JSON arrays converted to XML?
XML has no array type, so an array is written as repeated sibling elements that share the parent key as their tag name. For example {"item": [1, 2]} becomes <item>1</item><item>2</item> inside the enclosing element.
Why does XML need a root element name?
A well-formed XML document must have exactly one top-level element, while JSON can start with an object, an array, or even a bare value. The root name you type wraps everything, which is why it defaults to root and must be a valid XML name.
Can I add XML attributes instead of child elements?
Yes. Any object containing an "@attributes" object has those key/value pairs written as real attributes on the element, and a "#text" key becomes the element's text content. This matches the convention used by the XML to JSON converter, so data survives a round trip.
What happens to JSON keys that are not valid XML names?
XML element names cannot contain spaces or start with a digit. Keys like "first name" or "2nd" are rewritten to "first_name" and "_2nd", and a warning lists every rename so you can decide whether to fix the source data instead.
Does the converter escape special characters?
Yes. Ampersands, less-than, and greater-than signs in text are escaped as &, <, and >, and attribute values additionally escape double quotes. Without this, a single & in a product name would make the output unparseable.
What happens to null values and empty objects?
A null, an undefined, or an empty object is written as a self-closing element such as <note/>, which is the closest XML equivalent to an empty value. Numbers and booleans are written as their literal text form.
Is my JSON kept private?
Yes. The conversion runs entirely in your browser using plain JavaScript — nothing is sent to a server, logged, or stored. API payloads and customer records are safe to paste here.
Tips for Converting JSON to XML
- Tip 1: Pick a root name that matches what the receiving system expects — rss, Envelope, urlset, or the element named in its XSD — rather than leaving the default.
- Tip 2: Use an "@attributes" object when the target schema stores identifiers as attributes; it keeps ids out of the element body and produces far shorter XML.
- Tip 3: Read the rename warning carefully. A key silently turning into an underscore form usually means your JSON is using display labels where it should be using stable field names.
- Tip 4: Verify a mapping by converting the XML straight back with the XML to JSON converter, and shrink payloads before transport with the JSON minifier.