JSON to XML
Convert JSON to XML format online instantly. Free JSON to XML converter with proper nesting, attributes, and formatted output.
About JSON to XML Conversion
Convert JSON data to XML format. Arrays are converted to repeated elements with the same name. Special characters are automatically escaped to ensure valid XML output.
How to Use JSON to XML
Paste your JSON
Paste your JSON object or array into the input editor. The converter handles both single objects and arrays of objects.
Choose options
Select root element name (defaults to <root>), attribute prefix convention (@ or _), and pretty-print vs compact output.
View XML output
JSON keys become XML element names; nested objects become nested elements; arrays become repeated elements with the parent's key name.
Copy or download
Click Copy to put the XML on your clipboard, or Download to save as a .xml file. Use it in SOAP services, legacy systems, or any XML-consuming context.
When to Use JSON to XML
Posting to legacy SOAP services
When integrating with old SOAP endpoints (banking, insurance, government APIs, ERP systems), you need XML. Convert your modern JSON API client output to XML before posting. Combined with proper SOAP envelope wrapping, this bridges JSON-first development to XML-required services.
Generating compliance reports
Many compliance frameworks (HIPAA, financial reporting, government submissions) require XML format. If your application generates data in JSON, convert to XML for these specific compliance outputs without rewriting the whole pipeline.
B2B data exchange with XML-only partners
Some business partners require XML for EDI (Electronic Data Interchange), invoicing, or supply chain integration. Convert your internal JSON data to their required XML format at the integration boundary, keeping your internal systems modern.
Generating XML configuration for legacy systems
Tomcat, Spring (older versions), MSBuild, log4j, and many older Java/.NET tools use XML configs. If you're storing config in JSON internally and need to produce these XML configs (for deployment, migration, or templating), convert as the final step.
JSON to XML Examples
Simple JSON object
{"name":"Alice","age":30}<root>
<name>Alice</name>
<age>30</age>
</root>Object keys become element names. The JSON object is wrapped in a <root> element since XML requires a single root. Values become text content inside elements.
Array of objects
{"users":[{"name":"Alice"},{"name":"Bob"}]}<root>
<users>
<name>Alice</name>
<name>Bob</name>
</users>
</root>JSON arrays become repeated XML elements. The parent key (users) wraps the repeated child elements (name). Some converters wrap each array element in <user> tags for clarity — depends on your converter's mode.
Attributes via @ prefix
{"book":{"@id":"1","title":"Hamlet","author":"Shakespeare"}}<root>
<book id="1">
<title>Hamlet</title>
<author>Shakespeare</author>
</book>
</root>Keys prefixed with @ are converted to attributes (id) instead of child elements. This convention lets you generate XML that distinguishes attributes from elements — important for schemas that expect specific attribute placement.
Tips & Best Practices for JSON to XML
- 1.Plan your XML structure first. JSON's key/value model maps to XML element/text content, but the inverse (XML attribute distinction) needs intentional encoding. Use @-prefix conventions for attributes from the start.
- 2.For SOAP envelopes, you'll typically wrap the converted XML in <soap:Envelope><soap:Body>...</soap:Body></soap:Envelope>. The converter produces the inner content; SOAP wrapping is added separately.
- 3.Validate against your XSD schema after conversion. JSON-to-XML produces structurally correct XML but may not match a specific schema — the JSON might need restructuring to produce schema-conformant output.
- 4.For round-trip preservation (XML → JSON → XML), use libraries that support consistent conventions on both directions (fast-xml-parser is bidirectional). Without care, structural information can be lost.
- 5.Pretty-printed XML is easier to debug; compact XML is smaller for transmission. Use pretty for development and CLI tools, compact for production network traffic — gzip compresses both effectively.
- 6.Watch for XML reserved characters (<, >, &, ", ') in JSON values. They get auto-escaped to <, >, &, ", ' in the XML output. The converter handles this; verify before manually editing the XML output.
Frequently Asked Questions
Related Tools
XML to JSON
Convert XML to JSON format online instantly. Free XML to JSON converter with proper structure mapping and clean formatted output.
JSON to YAML
Convert JSON to YAML format online instantly. Free JSON to YAML converter for configuration files with clean indented output.
YAML to JSON
Convert YAML to JSON format online instantly. Free YAML to JSON converter for parsing configuration and data files accurately.
JSON to CSV
Convert JSON arrays to CSV format online. Free JSON to CSV converter for exporting data to spreadsheets with proper formatting.
CSV to JSON
Convert CSV data to JSON format online. Free CSV to JSON converter with header detection and properly structured array output.
CSV JSON Converter
Convert between CSV and JSON formats online with bidirectional support. Free converter with delimiter options and data preview.