Skip to content

Install ALink Tools

Free browser tools for images, PDFs, media, text and web checks. Most tools process files locally on your device.

  1. Tap the Share button in the Safari toolbar.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add. ALink Tools then opens from your Home Screen like an app.

JSON to XML

Paste JSON and get XML in this tab with fast-xml-parser (MIT). Object keys become elements. Keys that start with @ become attributes, and #text is character data. If the JSON would produce more than one top-level element, it is wrapped in a root element. Nothing is uploaded.

Runs in your browserfast-xml-parser (MIT)Nothing is uploaded
1

JSON

2

XML

How to use JSON to XML

  1. Paste or open JSONType, paste, or open a .json file. The limit is 1 MB of UTF-8 text.
  2. Choose XML optionsPick an indent of 2 or 4 spaces, or compact XML. You can include an XML declaration and set the root or array item names used when the document needs wrapping.
  3. Copy or downloadCopy the XML or download output.xml. If the JSON is invalid or a key is not a valid XML name, an error is shown instead.

Limits and how it works

  • The input is limited to 1 MB of UTF-8 text, including files you open. The document may have at most 64 levels and 100,000 nodes.
  • Every element and attribute name must be a valid XML 1.0 name. Keys such as foo bar or 123 are rejected rather than rewritten.
  • Keys named __proto__, prototype, or constructor are rejected. XML 1.0 illegal control characters in text are rejected.
  • Attribute prefixes are not given xmlns declarations automatically. This converter does not evaluate DTDs or expand custom entities, because it writes XML from JSON rather than reading an XML document.

How JSON becomes XML

This page converts JSON to XML with fast-xml-parser 5.12.1 (MIT). It does not format existing XML; use XML Formatter for that. It also does not convert XML back to JSON; that is a separate tool.

A JSON object with a single key, when that key is a valid XML name and the value is not an array, becomes the root element. Several top-level keys, a top-level array, a single value, or a single key whose value is an array are wrapped in a root element (default root) so the result is one well-formed document. Array items use the item name you set (default item).

A key that starts with @ is written as an attribute on the same element (for example @id becomes id). A #text key is the element’s character data, so you can have attributes and text together. Text is escaped (&, <, and >). The MIT license notice is kept at /notices/fast-xml-parser-5.12.1.txt.

Frequently asked questions

Is my text or file uploaded?

No. Everything runs in your browser tab with JavaScript. Nothing you type, paste or drop is sent to a server, logged or stored by ALink Tools.

Is this the same as XML Formatter?

No. XML Formatter pretty-prints or minifies XML you already have. This page starts from JSON and writes a new XML document.

Why was a root element added?

A well-formed XML document has one root element. If your JSON has several top-level keys, is an array, or is a single value, the converter wraps it in the root name you chose.

How do I add attributes?

Use a key that starts with @, such as @id. Use #text for the element’s text when it also has attributes.

Can I convert XML back to JSON here?

No. This page only writes XML from JSON. XML to JSON is a separate converter.

Related tools

All tools