My Tool Studio
Developer Tools·2 min read

JSON to XML: Convert Data for Feeds and SOAP

Some systems still speak XML: SOAP services, product feeds and older import tools. If your data is JSON, the JSON to XML Converter rewrites it as well-formed XML and updates as you type. Paste JSON, drop or upload a .json file, or load one from a URL, then copy or download the result. It runs in your browser.

.json.xmlJSON → XML

How the conversion works

Structure carries over.

Nested objects become nested elements. Array items repeat their element name, so a tag key holding two values becomes two tag elements. When the whole JSON is an array, each item is wrapped in the array item element inside the root.

An XML document can have only one root element. If your JSON has several top-level keys, or is an array or a plain value, the converter wraps everything in the root element you name. If it is an object with one key whose value is not an array, that key becomes the root.

Root names, item names and attributes

The settings that shape the output.

Type a Root element name and an Array item element name so the output matches what the receiving system expects. The XML updates as you type, so you can compare names straight away.

Keys that start with the attribute prefix, @ by default, become attributes while Keys with a prefix become attributes is ticked. A book object with an @id key and a title becomes a book element with an id attribute and a title child. If your JSON marks attributes with _, - or $ instead, pick that prefix. A #text key sets an element's text. This is a common convention for writing XML as JSON.

Keeping the XML valid

Handled for you.

XML element names have stricter rules than JSON keys. Characters other than letters, digits, underscores, hyphens, periods and colons are replaced with underscores, and a name that starts with a digit, hyphen or period gets a leading underscore. So first name becomes first_name and 2024 becomes _2024. Characters such as &, < and > inside values are escaped as entities.

What does not survive the trip

XML text has no data types.

The conversion is not fully lossless. XML text has no types, so the number 1, the string 1 and true all become plain text, and null becomes an empty element. Renamed keys also change.

The layout is up to you. Indent with 2 or 4 spaces or tabs, or pick Minified for one line. Untick XML declaration if the receiving system does not want the first line, and untick Self-close empty elements to write <notes></notes> instead of <notes/>.

Converting XML back to JSON

The return trip.

The XML to JSON Converter handles the reverse. Set its attribute prefix to @, or use the same prefix in both tools, and attributes survive the round trip without renaming. If your JSON will not parse in the first place, the error line is highlighted here, and the JSON Validator gives a fuller report.

Try it now

Open JSON to XML Converter

The tool is one click away. No sign up, no upload, no payment.

Open JSON to XML Converter