XML to JSON Converter - Free Online XML2JSON Tool
Convert XML to JSON directly in your browser - the conversion runs on your device, and your XML is never uploaded to a server. Paste XML or upload a file, and the tool converts it to JSON the moment input is detected. Set the output indentation, choose your own attribute prefix, and inspect the result in an interactive tree view before you copy or download it. Built for developers reshaping API responses, config files, RSS feeds, and SOAP payloads into JSON - free, with no sign-up required.
How XML Maps to JSON
The converter follows the standard, lossless mapping rules developers expect. Element names become JSON keys and element text becomes values. XML attributes are preserved as prefixed keys - id="101" becomes "@id": "101" by default, so attributes never collide with child elements. When the same tag repeats inside a parent - several <employee> elements, for example - the converter outputs a JSON array; a tag that appears once stays a single object. The XML declaration is dropped, since JSON has no equivalent. If the input is not well-formed XML - an unclosed tag, mismatched casing, or a stray & - the output reports "Invalid XML format" instead of returning broken JSON.
Custom Indentation and Attribute Prefix
Choose an indentation level from 2 to 10 spaces for the JSON output, so the result matches your project's formatting conventions before you download it. The attribute prefix is fully customizable: the default is @, and you can replace it with any string - _, $, or a project-specific marker - and the output updates in real time. This matters when the JSON feeds a downstream parser with its own naming rules, or when your codebase already standardizes on a particular attribute convention.
Five Ways to View the Output
How to Use Our XML to JSON Converter
- Paste your XML into the input box, click Upload to select an .xml file, or click Sample to see the mapping with example data.
- Pick the indentation level (2-10 spaces) and set a custom attribute prefix if your project needs one - the default is @.
- The tool converts automatically as soon as it detects valid input. You can also trigger conversion manually with Convert to JSON.
- If the XML is malformed, the input is flagged and the output reports Invalid XML format. Fix the markup - the JSON regenerates on its own. To debug the XML first, run it through the Free XML Beautifier, XML Minifier, and XML Validator Online tool.
- Switch output views to inspect the structure, then copy the JSON to your clipboard or download it as a file.