Convert XML to JSON
Paste XML from an RSS feed, a sitemap, a SOAP response or a config file and get JSON you can read and use in code. Attributes are kept, and elements that repeat become arrays.
- Free
- Runs in your browser
- Attributes kept
- No sign-up
How It Works
Convert XML in three steps.
Paste XML
A whole document or a single element with its children.
Adjust the mapping
Choose the attribute prefix and whether children are always arrays.
Copy or download
Copy the JSON or save it as converted.json.
How XML maps to JSON
XML has things JSON lacks, such as attributes and mixed text, so every converter follows a convention. This one uses the common one: an element becomes a key, its attributes become keys starting with @, an element with only text becomes that text, and an element that appears several times under the same parent becomes an array. When an element has both attributes or children and its own text, the text goes under "#text".
Comments and processing instructions are left out, and namespace prefixes stay part of the key (dc:title). The converter goes one way; JSON has no standard way back to attributes.
Attributes
<book id="7"> becomes "book": {"@id": "7", …}. Change the prefix, or clear it, to suit your code.
Consistent arrays
Always use arrays makes every child an array, so code does not break when a feed has one item instead of two.
Optional types
Numbers and true/false can be converted; leading zeros and long numbers stay text.
Safe parsing
Uses the browser's XML parser, which does not fetch external entities or run scripts.
Convert PDF Files and File Formats
Find the perfect online tool to combine PDF files, compress documents, and handle your daily workflow effortlessly.
PDF Tools
All your PDF needs in one place
- Merge PDF
- Organize PDF
- Split PDF
- Compress PDF
- Convert to Word
- Convert to Image
Image Tools
Edit and optimize your images
- Resize Image
- Compress Image
- Convert Format
- Crop Image
- Add Watermark
- Remove Background
Word Tools
Work with Word documents
- Convert to PDF
- Merge Documents
- Split Documents
- Compress File
- Edit Text
- Add Watermark
Excel Tools
Process Excel spreadsheets
- Convert to PDF
- Convert to CSV
- Merge Sheets
- Split Sheets
- Compress File
- Clean Data
Why Use This Converter
Readable JSON from any XML.
Clear errors
Malformed XML shows the parser's message instead of half a result.
Array control
Choose between compact output and consistent arrays.
Feeds and sitemaps
Handy for RSS, Atom, sitemaps and SOAP responses.
Private
Converted in your browser, nothing uploaded.
Frequently Asked Questions
Questions people ask about the XML to JSON converter.
An element that appears once becomes a single value; one that appears more than once under the same parent becomes an array. Tick Always use arrays for child elements to make every child an array.
They are keys starting with @ inside the element's object, such as "@id". Set Attribute prefix to another character, or leave it empty, to change that.
Yes. CDATA content is treated as the element's text.
Only HTML that is also well-formed XML (XHTML). Ordinary HTML, with tags such as <br> left open, is reported as an error.
Related Text & Developer Tools
More small utilities that run in your browser.
JSON to XML
Convert JSON to well-formed XML.
YAML to JSON
Convert YAML to JSON, with errors shown by line.
JSON Formatter
Format, validate and minify JSON.
JSON Flatten & Unflatten
Flatten nested JSON to dot keys or rebuild it.
TSV to JSON
Convert tab-separated data to JSON and back.