🍋 Developer Tools
XML ↔ JSON Converter
Convert between XML and JSON formats
chars
words
sentences
lines
Options
Type or paste something into the Input box to enable this button.
Results
None found.
Result
About XML ↔ JSON Converter
Convert XML documents to JSON or JSON back to XML. Uses the browser's built-in DOMParser for accurate XML parsing.
How It Works
For XML to JSON: uses the browser's DOMParser to parse XML, then recursively walks the DOM tree to build a JSON representation. Attributes are prefixed with @. For JSON to XML: recursively converts JSON objects to XML elements.
Step by Step
- 1 Paste XML or JSON data in the input area
- 2 Select direction: XML → JSON or JSON → XML
- 3 Set indentation for formatted output
- 4 Click Convert
Tips
- XML attributes are represented as @attr in JSON
- Text content of elements is stored as #text in JSON
- Use 2-space indentation for more compact output
Frequently Asked Questions
How are XML attributes handled?
Attributes are prefixed with @ in JSON output. For example, <item id='1'> becomes {"@id": "1"}.
Does this preserve XML namespaces?
Namespace prefixes are preserved in element and attribute names but not resolved to URIs.