Contact

Tools  /  JSON  /  JSON → XML

JSON → XML

Convert a JSON object into an XML document -- customizable attribute prefix, text key, root tag, array wrapping, CDATA, self-closing tags, boolean/null representation, and a well-formedness check.

What this tool does

Paste a JSON object and get back an XML document representing the same data, using the same @attribute and #text convention as this site's XML → JSON converter — so converting one way and then the other returns the original structure rather than a slightly different one.

Fixing JSON keys that are not valid XML names

JSON keys can be almost anything, but XML element names cannot start with a digit, cannot contain most punctuation, and cannot start with the letters "xml". A key that breaks any of those rules is corrected automatically — invalid characters replaced, a leading underscore added where needed — and every renamed key is listed afterward, showing exactly what changed instead of silently rewriting a name with no record of it.

Controlling exactly how the output looks

  • Root tag, attribute prefix, text key, and the tag used for array items are all editable.
  • Wrap arrays in a container — wraps repeated values in a single parent element instead of leaving them as plain sibling tags.
  • CDATA — wraps text content in a CDATA section instead of escaping it.
  • Self-close empty tags, an XML declaration toggle, and a choice of indentation or fully compact output.

Verifying its own output

After generating the XML, it is parsed right back using the browser's own XML parser to confirm it is genuinely well-formed — the result is checked rather than simply assumed to be correct, and the outcome is shown alongside a structure summary of elements, attributes, and nesting depth.

Privacy

Parsing and conversion both happen in your browser. Nothing you paste, drop, or load from a file is sent to a server.

Frequently asked questions

Is my data uploaded anywhere?
No. Parsing and conversion both run locally in the browser — nothing is sent to a server.
Why would a JSON key need to be changed for XML?
XML element names cannot start with a digit, cannot contain most punctuation, and cannot start with the letters xml, while JSON keys have almost no such restriction. Any key that breaks those rules is corrected automatically, and every renamed key is listed in the summary so the change is visible rather than silent.
Does this pair with the site's XML to JSON tool for a round trip?
Yes — both use the same @attribute and #text convention by design, so converting JSON to XML here and then back to JSON with the other tool returns the original structure rather than a different one.
What does wrapping arrays in a container do?
Without it, a repeated value becomes a series of plain sibling elements with the same tag name. With it turned on, those elements are wrapped inside one parent element instead, using a configurable tag for each item.
What is CDATA and when would it be useful?
A CDATA section tells an XML parser to treat its contents as literal text rather than markup, which is useful for text that itself contains characters like angle brackets that would otherwise need escaping.
How can the generated XML be confirmed as actually valid?
It already is, automatically: after generating the XML, the tool re-parses its own output with the browser's XML parser and reports whether the result is genuinely well-formed, rather than assuming the conversion succeeded.
Theme Accent