Why convert JSON to XML
Modern APIs speak JSON; some ERP and legacy systems still require XML. Hand-building tags is slow. ComTools JSON to XML (Tools/Json/ToXml) converts JSON to UTF-8 XML locally in the browser.
For spreadsheet rows, use Excel to XML (<Rows>/<Row> flat layout).
Conversion rules
| Item | Details |
|---|---|
| Root | Default element root |
| Objects | Each key → child element (sanitized tag name) |
| Arrays | Each entry wrapped in <item>...</item> |
| Text | Escapes & < > " |
| Declaration | <?xml version="1.0" encoding="UTF-8"?> |
Invalid characters in keys become _; tags starting with a digit get a _ prefix.
Steps
- Open JSON to XML.
- Paste JSON (validate / format first if needed).
- Click Run and copy the XML.
Nothing is uploaded.
Example
Input:
{
"user": {
"id": 1,
"name": "ComTools"
},
"tags": ["json", "xml"]
}
Output sketch:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<user>
<id>1</id>
<name>ComTools</name>
</user>
<tags>
<item>json</item>
<item>xml</item>
</tags>
</root>
Pretty-print afterward with XML Formatter if needed.
Common scenarios
| Scenario | Approach |
|---|---|
| API sample → legacy XML | JSON → XML |
| Flat table XML | Excel to XML |
| Prefer YAML configs | JSON to YAML |
| Convert a subtree only | JSONPath first |
Notes
- Standard JSON required.
- SOAP-style attributes need extra tooling.
- Spot-check empty objects/arrays after convert.
Related tools
FAQ
Custom root name?
Default is root—replace in the output or map with XSLT.
Chinese keys?
Allowed; sanitized into valid tag names.
vs Excel to XML?
This tool keeps nesting; Excel export fits tabular rows.