🛠️DevTools

JSON to XML Attributes

Properties starting with @ are converted to XML attributes on the parent element.

Switch tool:
Examples:
XML output will appear here...

💡 Paste your JSON and it converts to XML automatically. Properties starting with @ become XML attributes.

Code Examples

Here's how to achieve this in different programming languages:

1// Using xmlbuilder2 (npm install xmlbuilder2)
2const { create } = require('xmlbuilder2');
3
4const jsonData = {"book": {"@id": "1", "@category": "fiction", "title": "The Great Gatsby", "author": "F. Scott Fitzgerald"}};
5
6const xml = create({ version: '1.0', encoding: 'UTF-8' })
7 .ele(jsonData)
8 .end({ prettyPrint: true });
9
10console.log(xml);
11
12// Output:
13// <?xml version="1.0" encoding="UTF-8"?>
14// <book id="1" category="fiction">
15// <title>The Great Gatsby</title>
16// <author>F. Scott Fitzgerald</author>
17// </book>...

More JSON Examples

Related JSON Tools

📚 Learn More