From XML to JSON
XML is still everywhere in RSS feeds, SOAP services, config files and exports from business software, but working with it in code is more cumbersome than with JSON. This tool reads the XML and turns it into a JSON object.
Each element becomes a key; attributes are written as “@name”; repeated elements are grouped into an array; and when an element has text as well as attributes or children, the text goes in “#text”. Empty elements become null.
By default every value stays a string, just as in the XML. Turn on “Detect numbers and true/false” and numeric and boolean values come out with their type. If the XML isn't well-formed, you see the error and its line.
How to convert XML to JSON
- Paste the XML or open an .xml, .rss or .svg file.
- Choose whether to keep the root element and detect numbers.
- Click “Convert to JSON”.
- Copy the result or download it as a .json file.
When to use it
- Reading an RSS or Atom feed from a JavaScript app.
- Working with the response from a SOAP service.
- Migrating config or data exported as XML to a system that uses JSON.
- Inspecting a large XML file in a more compact form.
Frequently Asked Questions
How are attributes represented?
As keys with “@” in front: <product id="7"> becomes {"product": {"@id": "7"}}. It's the most widely used convention and the one our JSON to XML converter uses too.
Why is an element sometimes an object and sometimes an array?
If an element appears only once, it's a single value; if it repeats, it's an array. That's the usual way to convert XML, so keep it in mind if a feed can contain one item or several.
Are namespaces and CDATA preserved?
CDATA content is converted to plain text. Namespace prefixes are kept in the key name (for example “dc:creator”).
Is my data sent to a server?
No. Everything is processed in your browser with JavaScript. The text you paste and the files you open never leave your device, so you can safely work with internal or customer data.
Is it free?
Yes. You can try the tool for free on one document (pasted or a single file) and change the options as often as you like; attempts that end in an error don't use up your free try. For unlimited use and processing several files at once, ToolStudio Pro costs €1.99 a month and includes every tool.