Skip to main content

JSON to XML converter

Convert JSON data to XML format

No watermarkFree & unlimited
Mode
Input (JSON)
Output (XML)
All processing happens in your browser. No data is sent to any server.

Every JSON key becomes an element name and every value becomes that element content. If your document has exactly one top-level key, it is promoted to the root element; otherwise the whole structure is wrapped in a root tag so the output is well formed. Arrays repeat the parent tag once per item, nested objects nest elements two spaces deeper, and null becomes a self-closing tag. The file opens with a UTF-8 XML declaration. Nothing becomes an attribute: this writer produces an element-only document.

Key facts about JSON to XML converter

Key facts about JSON to XML converter
Root elementA single top-level key becomes the root. Anything else, including an array, is wrapped in a tag named root.
ArraysEach item is written as another element with the same name, so a list of three tags produces three tag elements.
AttributesNone are produced. Every key becomes a child element, whatever it was called in the source.
Key sanitisingAny character outside letters, digits, underscore and hyphen becomes an underscore, so first name becomes first_name.
NullsWritten as a self-closing element such as <note/>, which is how most XML consumers signal an empty value.
EscapingAmpersand, less-than, greater-than and double quote are escaped in text. The apostrophe is left as a literal.
IndentationTwo spaces per level, with each element on its own line, so the result is readable without a formatter.
DeclarationThe output starts with an XML declaration naming version 1.0 and UTF-8, and no DOCTYPE is written.
Numbers and booleansSerialised as their plain text form, so a consumer has to know the schema to type them back.
NamespacesNot emitted. If the destination expects a namespaced document, add the declarations to the root by hand.
ModesPaste and convert, or upload a .json file, with a copy button and character counts on both panels.
Invalid inputStrict JSON only. Trailing commas, comments and unquoted keys stop the conversion with a parse error.

What happens to your file

The conversion happens where you are sitting. Pasted JSON stays inside the input panel of this page, and an uploaded file is read locally with the File API before the browser own JSON parser turns it into a value. The XML is then built up as a string by a recursive writer running in this tab and offered as clipboard text or as a Blob download. No request carries your document anywhere, and nothing is retained once the tool is reset or the tab closed.

About this tool

  1. 1

    Select paste or upload

    Paste and convert is open by default; switch to file upload to convert a .json document from disk.

  2. 2

    Consider the root

    Wrap your data in a single named key if you want a meaningful root element instead of the generic root tag.

  3. 3

    Convert

    The writer walks the value, emitting an element per key and repeating tags for array items, indented two spaces.

  4. 4

    Add what XML needs

    If the target system expects a namespace, a schema location or a DOCTYPE, add those to the root element yourself.

  5. 5

    Copy or download

    Copy the markup to the clipboard, or save an .xml file when you converted from an uploaded document.

Specs & compatibility
Input and outputTakes .json (application/json) and returns the XML as a blob with the application/xml type, named after the file you dropped in.
EngineJSON.parse reads the file and a small string builder in the page writes the elements, escaping &, <, > and quotes as it goes - nothing is fetched to do it.
ModesBoth modes: paste the JSON in and copy the XML straight back out, or hand over a file and take the XML as a download.
Batch and capsTwenty JSON files per run at 500 MB each; several XML results are zipped in page memory as converted-xml-files.zip.
Browser and deviceJSON to XML needs only the File API, a Blob download and the parser already in the bundle, so every current browser behaves the same and the page keeps working with the network off.
  • Rename keys before converting rather than after. Spaces, dots, slashes and the at sign all become underscores, and fixing that in the XML afterwards means editing both the opening and the closing tag.
  • A key that starts with a digit produces an element name that is technically invalid XML, so rename such keys at the source if a strict validator will read the output.
  • If a list must appear even when it has one item, remember that a JSON array of one still emits one element, which is indistinguishable from a single value to the consumer.
  • The apostrophe is left unescaped in text content, which is valid XML, but a downstream tool that parses attributes naively may still trip on it.
  • Converting JSON that came from the XML to JSON tool will not restore the original document, because the @attributes container becomes an element rather than real attributes.
  • Feed a legacy system, an enterprise integration bus or a SOAP endpoint that accepts only XML, starting from a modern JSON payload.
  • Produce a quick XML fixture for testing a parser or an XSLT stylesheet without hand-writing the markup.
  • Hand configuration data to a tool whose reader predates JSON, such as an older build or reporting system.
If the top level of your JSON is an object with exactly one key, that key is used as the root and its value fills the document. In every other case, including an array or an object with several keys, the writer wraps everything in a tag literally named root so that the output has the single root element XML requires. Wrap your data yourself to control the name.
No. The writer maps every key onto a child element, which keeps the rules simple and the output predictable, at the cost of not being able to express attributes. If the receiving system requires them, convert here to get the structure and then move the relevant values onto the parent tags with an XSLT stylesheet or a short script.
Element names cannot contain arbitrary characters, so anything outside letters, digits, underscore and hyphen is replaced with an underscore before the tag is written. A key such as user name becomes user_name and one called @id becomes _id. Rename the keys in the JSON first if the destination expects particular element names.
A null or an undefined value produces a self-closing element with no content, such as <middleName/>, which most consumers read as present but empty. An empty string produces an element with nothing between its tags, and an empty object produces an element containing only whitespace and a closing tag. None of these are omitted from the document.
No schema is involved at any stage. The writer guarantees well-formedness through escaping and consistent tag pairing, but it knows nothing about what your target system expects, so element order, cardinality and data types are entirely up to your input. Validate the result against your XSD separately before sending it to a strict endpoint.
You can run both tools, but the round trip is not lossless. The XML to JSON direction stores attributes under an @attributes key and text under #text, and coming back the other way turns those into elements named _attributes and _text rather than restoring their original roles. Treat each direction as a transformation, not as a reversible encoding.
View all

Need the opposite? Try XML to JSON

Updated

We use anonymous analytics to improve ToolChamp. No personal data is stored or sold. Privacy Policy