Simple XML to JSON
Simple XML elements are converted to JSON properties. Boolean and number values are automatically parsed.
Switch tool:
Examples:
JSON output will appear here...
💡 Paste your XML and it converts to JSON automatically. Attributes are prefixed with @ and text content uses #text.
Code Examples
Here's how to achieve this in different programming languages:
1// Using DOMParser (browser) or xml2js (Node.js)2const xmlString = `<person>3 <name>John Doe</name>4 <age>30</age>5 <active>true</active>6</person>`;78// Browser9const parser = new DOMParser();10const doc = parser.parseFromString(xmlString, 'text/xml');1112// Node.js with xml2js (npm install xml2js)13const xml2js = require('xml2js');14const parser = new xml2js.Parser();15parser.parseString(xmlString, (err, result) => {16 console.log(JSON.stringify(result, null, 2));17});1819// Output:20// {21// "person": {22// "name": "John Doe",23// "age": 30,24// "active": true...
More XML Examples
XML Attributes to JSON
XML elements with attributes converted to JSON with @ prefixed properties.
Nested XML to JSON
Deeply nested XML structures converted to nested JSON objects.
RSS Feed to JSON
Transform RSS feed XML into JSON format for web apps.
SOAP Response to JSON
Transform SOAP web service responses to JSON format.
XML Config to JSON
Transform XML configuration files to JSON format.