᠎᠎᠎          
51K

XML to JSON Converter

World's simplest json tool
Free online XML to JSON converter. Just load your XML in the input field and it will automatically get converted to JSON. In the tool options, you can choose whether to use spaces or tabs for indentation and if you're using spaces, you can set the number of spaces per indentation level. Created for developers by developers from team Browserling.
Check out our main project! Browserling
We created Browserling – get a cloud browser in 5 seconds. Check it out!
JSON Indentation
Spaces are used for indentation.
Set the number of spaces per indent (usually 2 or 4). Indent "0" means minified JSON.
Tabs are used for indentation.

What is a XML to JSON Converter?

learn more about this tool
This tool converts Extensible Markup Language (XML) documents into JavaScript Object Notation (JSON) configuration files. XML is a markup language that uses tags, keys, and values to define elements within a document. It's commonly used in web development, data exchange between various systems, and configuration files. Unfortunately, it has an extremely verbose structure that can lead to huge file sizes, increased complexity, and slower parsing times. On the other hand, JSON is a lightweight data exchange format based on JavaScript's syntax of object literals. It's known for its simplicity and readability and it's used for transmitting data between servers and web applications, storing configuration settings, and as a format for APIs. When you convert XML into JSON with this tool, it will create object literals that can be used directly in JavaScript. In the tool's options, you can choose your preferred JSON indentation style, using either spaces or tabs. If you choose spaces, you can specify the number of spaces per indent level. Additionally, you can set the number of spaces to zero to minify the output JSON. If you need to convert JSON back into XML, you can use our Convert JSON to XML tool. Json-abulous!

XML to JSON Converter examples

Click to use
Convert a Simple XML to JSON
In this example, we transform XML data into JSON data. The input XML contains a single tag "color" with the contents "red". As a result of the conversion, the "color" tag becomes a key in the JSON object, with "red" as its value. We also use spaces for indentation, with two spaces per indent level.
<root> <color>red</color> </root>
{ "color": "red" }
Required options
These options will be used automatically if you select this example.
Spaces are used for indentation.
Set the number of spaces per indent (usually 2 or 4). Indent "0" means minified JSON.
Convert XML Weekdays Data to JSON
This example converts bulky and unformatted XML with multiple elements containing weekday definitions into simple and understandable JSON. The program discards the XML meta tag containing the XML version and character set used at the beginning of the data and turns just the XML elements and their values into key-value pairs of a JSON object. For better readability, it formats JSON using tab indentation.
<?xml version="1.0" encoding="UTF-8" ?><root><day-1>Sun</day-1><day-2>Mon</day-2><day-3>Tue</day-3><day-4>Wed</day-4><day-5>Thu</day-5><day-6>Fri</day-6><day-7>Sat</day-7></root>
{ "day-1": "Sun", "day-2": "Mon", "day-3": "Tue", "day-4": "Wed", "day-5": "Thu", "day-6": "Fri", "day-7": "Sat" }
Required options
These options will be used automatically if you select this example.
Tabs are used for indentation.
Turn a Nested XML into JSON
In this example, we transform XML data describing animal habitats into JSON format. The input XML has a hierarchical structure consisting of nested elements, including information about the animal, its habitat location, climate, and population. We also set the indentation to zero spaces, which means the output JSON gets minified and printed with no indentation or leading spaces.
<root> <animal>Tiger</animal> <habitat> <location>Jungle</location> <climate>Tropical</climate> </habitat> <population>3900</population> </root>
{"animal":"Tiger","habitat":{"location":"Jungle","climate":"Tropical"},"population":"3900"}
Required options
These options will be used automatically if you select this example.
Spaces are used for indentation.
Set the number of spaces per indent (usually 2 or 4). Indent "0" means minified JSON.
Pro tips Master online json tools
You can pass input to this tool via ?input query argument and it will automatically compute output. Here's how to type it in your browser's address bar. Click to try!
https://onlinejsontools.com/convert-xml-to-json?input=%3Croot%3E%0A%20%20%3Ccolor%3Ered%3C%2Fcolor%3E%0A%3C%2Froot%3E&indent-use-spaces=true&indent-spaces=2
All json tools
Didn't find the tool you were looking for? Let us know what tool we are missing and we'll build it!
Quickly color-code the syntax of a JSON file.
Quickly beautify a JSON data structure.
Quickly compress a JSON file.
Quickly convert JavaScript data to a JSON string.
Quickly convert a JSON string to JavaScript data.
Quickly check JSON for errors and report them.
Quickly escape special JSON characters.
Quickly unescape an escaped JSON string.
Quickly convert a JSON data structure to an XML file.
Quickly convert an XML file to a JSON data structure.
Quickly convert a JSON data structure to a YAML markup.
Quickly convert a YAML markup to a JSON data structure.
Quickly convert a JSON file to a TSV file.
Quickly convert TSV data to a JSON file.
Quickly convert a JSON file to a CSV file.
Quickly convert CSV data to JSON data.
Quickly convert a JSON structure to binary JSON encoding.
Quickly convert JSON to a PNG, GIF, JPG, or BMP image.
Quickly create a screenshot from JSON code.
Quickly encode JSON to base64.
Quickly decode base64 to JSON.
Quickly convert JSON to URL-encoding.
Quickly convert URL-escaped JSON back to JSON.
Quickly convert JSON data to plain text.
Quickly edit a JSON file in a neat JSON editor in your web browser.
Quickly extract keys from objects in JSON data.
Quickly extract values from objects in JSON data.
Quickly reduce the nesting level of an array of arrays.
Quickly create a single-level JSON object from nested JSON objects.
Quickly rewrite JSON strings, keys, and values using escape codes.
Quickly obfuscate a JSON data structure.
Quickly remove certain information from a JSON data structure.
Quickly display detailed information about a JSON data structure.
Quickly convert a JSON file to properties file.
Quickly convert a properties file to a JSON file.
Coming soon These json tools are on the way
Find JSON Keys/Values
Find keys and/or values that interest you in a JSON file.
Convert JSON to a List
Create a text list from a JSON array or object.
Convert a List to JSON
Create a JSON array from a text list.
Convert JSON to Form Data
Generate HTTP form data from a JSON object.
Convert Form Data to JSON
Generate JSON object from HTTP form data.
Convert JSON to HTML
Create a HTML table from keys and values of a JSON object.
Convert JSON to CSON
Convert a JSON file to a CSON file.
Convert CSON to JSON
Convert a CSON file to a JSON file.
Convert JSON to TOML
Convert a JSON config to a TOML config.
Convert TOML to JSON
Convert a TOML file to a JSON file.
Convert JSON to Bencode
Convert a JSON data structure to Bencode encoding.
Convert Bencode to JSON
Convert Bencode data to JSON data.
Convert JSON to JSONL
Convert a JSON file to a JSONL file.
Convert JSONL to JSON
Convert a JSONL file to a JSON file.
Convert BSON to JSON
Convert binary JSON data structure (BSON) to JSON.
Convert JSON to UBJSON
Convert a JSON file to a universal binary JSON (UBJSON).
Convert UBJSON to JSON
Convert universal binary JSON (UBJSON) to regular JSON.
Convert JSON to Message Pack
Serialize JSON data to binary MessagePack format.
Convert Message Pack to JSON
Unserialize binary MessagePack to a JSON struct.
Convert JSON to Protobuf
Serialize JSON data to binary Protobuf format.
Convert Protobuf to JSON
Unserialize binary Protobuf to a JSON struct.
Convert JSON to a LaTeX Table
Generate a LaTeX table from a JSON object.
Convert JSON to INI
Convert a JSON data file to an INI configuration file.
Convert INI to JSON
Convert an INI configuration file to JSON data file.
Truncate JSON
Loop over JSON structure and truncate all values or keys.
Find JSON Depth
Find the nesting depth of a JSON data structure.
Convert JSON to a Data URI
Convert a JSON data structure to a data URL.
Convert JSON to a PHP Array
Create a PHP data structure from a JSON data structure.
Convert a PHP array to JSON
Create a JSON data structure from a PHP data structure.
Compare Two JSON Files
Diff JSON files and show differences visually.
Sort JSON Object Keys
Lexicographically sort the order of JSON object keys.
Swap JSON Keys with Values
Exchange keys with values in a JSON file.
Create a Random JSON Array
Create a JSON array with random values.
Create a Random JSON Object
Create a JSON object with random keys and values.
Randomize a JSON Array
Randomly change the positions of array elements.
Randomize a JSON Object
Randomly change the order of key, value pairs.
Add Spacing to JSON
Add random spaces and newlines in a JSON file.
Tokenize JSON
Tokenize a JSON data structure.
Remove JSON Syntax
Remove all JSON syntax and leave just the values.
Change JSON Syntax
Change curly braces, commas, and quotes to other symbols.
Fix Quotes in JSON
Fix incorrectly quoted (usually single quote) keys and values.
Use Single Quotes in JSON
Make all keys and values in a JSON to be single-quoted.
Use Double Quotes in JSON
Make all keys and values in a JSON to be double-quoted.
Generate FakeSON
Create JSON that looks real but is fake (FakeSON).
Run jq
Execute a jq query on a JSON data structure.
Filter JSON
Filter keys and values that match a pattern.
Split a String into a JSON Array
Create a JSON array from a string.
Group a JSON Array
Create groups of JSON array items.
Merge JSON Arrays
Merge two or more JSON arrays together.
Compare JSON Arrays
Find differences in two or more JSON arrays.
Merge JSON Objects
Merge two or more JSON objects together.
Damage JSON
Introduce errors in a JSON data structure.
Fix JSON
Try to fix a damaged JSON to the best of our ability.
Create JSON Art
Convert images to valid JSON strings that look like ASCII art.
Visualize a JSON Structure
Create an abstract visualization of JSON's complexity.