More options Root, arrays, nulls, CDATA, type hints, sorting
Converts as you type. Your JSON never leaves this browser.
About this tool
A free online JSON to XML converter that turns any JSON document into clean, well-formed XML while you type. Paste JSON, drop a .json file or open one, and the XML appears beside it with syntax highlighting. Keys that start with @ become attributes, #text becomes element text, and arrays become repeated elements or a wrapper with one child per item. Choose the root element, indentation, XML declaration, how null values are written, whether markup goes into CDATA sections, and how keys that are not valid XML names are repaired. Numbers keep their exact digits, broken JSON with comments or trailing commas is repaired automatically, and every result is checked for well-formedness before you copy it or download an .xml file. Conversion runs entirely in your browser; your data is never uploaded.
Features
Live conversion
The XML updates as you type, with no convert button. Large documents are converted without blocking the editor.
Attributes and text
Keys starting with @ (or -, _, $) become XML attributes, and #text becomes the element’s text, so {"price":{"@currency":"USD","#text":"9.99"}} gives <price currency="USD">9.99</price>.
Repeat or wrap arrays
Write ["a","b"] under "tag" as repeated <tag> elements, or as <tags><tag>a</tag><tag>b</tag></tags> with automatic singular names.
Smart root element
A single top-level key becomes the root element. Several keys, top-level arrays and single values are wrapped in a root you name.
Valid XML names
Keys with spaces, leading digits or symbols are turned into legal element names (first_name or first_x0020_name) and listed so you can review them. Namespace prefixes such as soap:Body are kept.
Nulls, CDATA and type hints
Write null as <a/>, xsi:nil="true" or leave it out. Optionally wrap markup in CDATA, and add type attributes so numbers, booleans, nulls and arrays survive a round trip.
Forgiving JSON input
Comments, trailing commas, single quotes, unquoted keys and Python True/False/None are repaired automatically, and real syntax errors point to the exact line and column.
Exact numbers
Numbers are copied digit for digit, so long IDs and precise decimals such as 12345678901234567890 or 0.10 are never rounded.
Well-formedness check
Every result is parsed again as XML to confirm it is well-formed, and stats show the element count, attributes, nesting depth and size change.
Round-trip check
The XML is converted back to JSON behind the scenes and compared with your input, so you can see at once whether any value would change. Make it lossless turns on the two options that keep types and one-item arrays.
XSD schema generator
Switch the output to XSD to infer an XML Schema from the converted document, with element types, attributes, required and optional elements and repeated elements.
Sorting and ASCII output
Write elements and attributes in alphabetical order for stable diffs, and escape accented letters and emoji as é references for systems that accept only 7-bit ASCII.
Share links and shortcuts
Copy a link that reopens the same JSON and options; the data travels in the link fragment and never reaches our servers. Ctrl/⌘ + S downloads and Ctrl/⌘ + Shift + C copies the result.
Format, copy and download
Pretty-print with 2 or 4 spaces or tabs, or minify to one line. Copy the XML, download an .xml file, or maximize either editor for long documents.
Private by design
JSON is converted in your browser and never sent to a server. Your options are remembered on this device only.
How JSON maps to XML
JSON and XML describe data differently. JSON has objects, arrays, strings, numbers, booleans and null; XML has elements, attributes and text. There is no single official mapping, so this converter uses the widely recognised convention that most libraries and APIs share.
Each object key becomes a child element and each scalar value becomes that element’s text. Keys that start with the attribute prefix become attributes of their parent, and the text key supplies text beside those attributes. Arrays become one element per item. Special characters are escaped (&, <, >), and characters that XML 1.0 does not allow are removed.
{"order":{"@id":"A1","item":["pen","ink"],"note":{"@lang":"en","#text":"Gift"}}}
<order id="A1">
<item>pen</item>
<item>ink</item>
<note lang="en">Gift</note>
</order>Converting JSON arrays to XML
XML has no array type, so a list is written as several elements with the same name. In Repeat mode, {"book":[…]} produces one <book> element per item, which is the most common shape for SOAP messages, feeds and data exports. An empty array produces no elements in this mode, and the converter tells you when that happens.
Wrap mode keeps the array as a container: {"books":[…]} becomes <books> with a <book> child for each item. Singular names are derived from common English plurals (categories → category, boxes → box); when no singular is found, the item element name from More options is used. A JSON document whose top level is an array is always wrapped in the root element.
Root elements and valid XML names
A well-formed XML document has exactly one root element. When your JSON is an object with a single key whose value is an object, that key becomes the root. Otherwise the content is placed inside the root element you choose, which is <root> by default.
XML element names cannot start with a digit or contain spaces and most punctuation, while JSON keys can be any string. Invalid characters are replaced with an underscore, or with a reversible _xHHHH_ escape that many .NET and SQL Server tools understand. Every renamed key is listed under the editors.
Keeping data types in a round trip
XML text has no types, so 42, true and "42" all look the same once converted. If the XML will be turned back into JSON, turn on Type attributes: elements get type="number", "boolean", "null" or "array" (and "string" or "object" for empty values), and the XML to JSON converter reads them to restore the original values, even single-item and empty arrays when arrays are wrapped.
Use the same attribute prefix and text key in both directions and select Swap to check the round trip on your own data.
How to use it
- Paste JSON into the left editor, drop a .json file on it, or select Sample to try an order, an API array or a config file.
- Pick how arrays are written (Repeat or Wrap), the attribute prefix, indentation and whether to add the XML declaration. Open More options for the root element, item names, nulls, CDATA, type attributes and invalid-name handling.
- Check the round-trip status below the editors, switch to XSD for a schema, then copy, download or share the result. Select Swap to continue in the XML to JSON converter.
Common uses
- Send JSON data to SOAP services, legacy enterprise systems and XML-only APIs
- Generate XML configuration, feeds, sitemaps-style documents or test fixtures from JSON
- Migrate records from REST/JSON APIs into XML-based integrations, ETL jobs and message queues
Common questions
How do I convert JSON to XML?
Paste or open your JSON in the left editor. The XML appears on the right immediately. Adjust arrays, attributes, indentation and the declaration if needed, then copy it or download converted.xml.
How do I create XML attributes from JSON?
Start the key with the attribute prefix, @ by default: {"user":{"@id":"7","name":"Ava"}} becomes <user id="7"><name>Ava</name></user>. You can switch the prefix to -, _ or $, or choose None to write every key as an element.
How is a JSON array converted to XML?
In Repeat mode each item becomes an element named after the array’s key. In Wrap mode the key becomes a parent element with one child per item, named with the singular of the key or the item name you set. Top-level arrays are wrapped in the root element.
What happens to null values?
By default null becomes an empty element such as <middleName/>. You can instead write xsi:nil="true", which adds the XML Schema instance namespace to the root, or omit null keys entirely.
My JSON has keys with spaces or numbers. Is the XML still valid?
Yes. Invalid names are repaired, for example "first name" becomes <first_name> and "2024" becomes <_2024>, and each change is listed below the editors. Namespace prefixes such as soap:Envelope are kept.
Can it convert invalid or JSON5-style input?
With Auto-repair on, comments, trailing commas, single-quoted strings, unquoted keys and Python True/False/None are accepted and the repairs are noted. Other syntax errors show the line and column, and Go to line moves the cursor there.
Are large numbers kept exactly?
Yes. Numbers are copied exactly as written instead of being converted to JavaScript numbers, so long identifiers and decimal places are not rounded or changed.
Can I convert XML back to JSON?
Yes. Select Swap to open the XML in the XML to JSON converter, or use the XML → JSON tab at the top. Turn on Type attributes first if you need the original number, boolean and array types restored.
Can it generate an XSD schema from JSON?
Yes. Switch the output view from XML to XSD. The schema is inferred from the converted XML: values such as 42, 9.99, true and 2026-01-31 become xs:integer, xs:decimal, xs:boolean and xs:date, repeated elements get maxOccurs="unbounded" and attributes found on every element are marked required. Review it before use, because one sample cannot show every optional element.
How do I know whether converting back will give the same JSON?
The round-trip status under the editors converts the XML back with matching options and compares it with your input. If something changes, such as the string "42" becoming a number or a one-item array becoming a single value, it names the first difference and offers Make it lossless.
Can I share a conversion with a colleague?
Yes. The share button copies a link containing your JSON and options in the URL fragment, which browsers do not send to servers. Anyone with the link sees the same input, settings and XML. Very large documents make very long links, so download the file instead.
How large a file can I convert?
Files up to 10 MB can be opened or dropped onto the editor. Conversion happens in your browser, so very large documents depend on your device’s memory.
Is my JSON uploaded anywhere?
No. The JSON is parsed and converted by JavaScript in this browser tab. Nothing you paste or open is sent to TheVanTool’s servers.
Can’t find the tool you need?
Tell us what you’d like it to do. We’ll review your suggestion for a future tool.