Overview
Convert JSON into an XML document with a configurable root element and two-space or four-space indentation. Objects become nested elements, arrays become repeated sibling elements, and scalar text is escaped. Everything is processed locally in the browser.
How It Works
The tool starts with a sample bookstore object so you can see the element mapping at once. Set the root element name in the toolbar (it is restricted to letters, digits, underscores, and hyphens), choose an indentation, and edit the JSON. The XML regenerates on every keystroke, with a Prettify button to reformat a mangled input. Both editors can download their contents, and clicking either panel copies the text.
Step-by-Step Usage Guide
- Edit the sample JSON or paste your own object.
- Type a root element name and pick 2 or 4 space indentation.
- Read the XML output and check that array keys repeat the way your consumer expects.
- Copy the XML or download it as a .xml file.
Technical Specifications & Standards
The converter walks the parsed JSON and emits elements recursively. Objects become parent elements with one child per key. Arrays are written as repeated sibling elements named after their key, so an array of two strings under the key tags becomes two tags elements rather than a wrapper element. That is a common convention but worth verifying if your consumer expects a wrapper. JSON null becomes a self-closing empty element. Text values escape the three characters that matter inside element content: ampersand, less-than, and greater-than; quotes are left alone because this output never places values inside attributes. The document is prefixed with an XML declaration specifying UTF-8. One structural caveat: JSON keys are used verbatim as tag names. A key starting with a digit, or containing a space, would produce markup that is not a well-formed XML name, so rename such keys first. Attribute-style conversion is deliberately not attempted, which keeps the mapping predictable.
Targeted Use Cases
- Feeding JSON data to a legacy system that only accepts XML input.
- Generating RSS-like or configuration payloads from modern API responses.
- Creating XML test fixtures from JSON examples.
- Demonstrating the JSON-to-XML mapping conventions with a live example.
Notes & Gotchas
- Rename JSON keys that are not valid XML names before converting.
- Confirm whether your target system wants repeated elements or a wrapper element for arrays.
- Use the Prettify button to normalize whitespace in the JSON before comparing outputs.
- Validate the result against your consumer's schema; the tool guarantees well-formed output only when keys are valid tag names.
Frequently Asked Questions
Why are my array items separate elements with the same name?
The converter repeats the parent key as one element per array item instead of inventing a wrapper. If your target expects a wrapping element, restructure the JSON so the array sits inside an object under its own key.
How are JSON null values represented?
As a self-closing empty element, for example a tag with no content. No nil attribute is added; the empty element is the tool's convention for absence of value.
Are quotes escaped in the output?
Only ampersand, less-than, and greater-than are escaped, because values are always written as element text, never as attributes. That is sufficient for well-formed element content.
Can JSON keys with spaces be converted?
They will be written verbatim, but the resulting markup is not valid XML because element names cannot contain spaces. Rename the key in the JSON first.