XML to JSON Converter
100% PrivateData & JSON ToolsParse XML and convert it into JSON you can use in code and tools.
Runs entirely in your browser. Your input is not uploaded to Ovatly or anywhere else.
Or upload an .xml file
- 1Paste XML text or upload an .xml file.
- 2Press Convert to JSON.
- 3Review the JSON, watching for @attributes and #text keys.
- 4Copy the result or download it as converted.json.
Worked example
Element with an attribute
Input: <person id="7"><name>Ana</name></person> Output: { "person": { "@id": "7", "name": "Ana" } }
- Attributes are written as @name keys. When an element has both text and child elements or attributes, the text is kept under #text; an element with only text becomes that text directly.
- Repeated sibling elements with the same tag become a JSON array; a single occurrence stays a single value, so shapes can vary between documents.
- XML comments, processing instructions and namespaces are not carried into the JSON. Namespace prefixes appear as part of tag names.
It preserves text that sits next to child elements or attributes, which would otherwise have nowhere to go in JSON.
About this tool
The XML to JSON Converter parses XML with the browser's built-in DOMParser and produces JSON using a clear convention: attributes become @keys, repeated elements become arrays, and text alongside elements is kept under #text.
Related tools
JSON to XML ConverterConvert JSON into well-formed XML using a documented, deterministic mappingData & JSON ToolsOpenJSON Formatter and ValidatorFormat JSON with your choice of indentation, validate it and explore its structureData & JSON ToolsOpenJSON to CSV ConverterConvert a JSON array of objects into a spreadsheet-ready CSV fileData & JSON ToolsOpenYAML to JSON ConverterConvert YAML configuration into strict JSON, and convert JSON back to YAMLData & JSON ToolsOpen
Advertisement
Part of Ovatly's free tools in Data & JSON Tools.