XML Config to JSON
XML configuration files convert to JSON for use with modern frameworks and JavaScript applications.
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 = `<config>3 <database>4 <host>localhost</host>5 <port>5432</port>6 <name>myapp</name>7 </database>8 <cache enabled="true">9 <ttl>3600</ttl>10 </cache>11</config>`;1213// Browser14const parser = new DOMParser();15const doc = parser.parseFromString(xmlString, 'text/xml');1617// Node.js with xml2js (npm install xml2js)18const xml2js = require('xml2js');19const parser = new xml2js.Parser();20parser.parseString(xmlString, (err, result) => {21 console.log(JSON.stringify(result, null, 2));22});2324// Output:25// {26// "config": {27// "database": {28// "host": "localhost",29// "port": 5432,...
More XML Examples
Simple XML to JSON
Basic XML element conversion to JSON object.
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.