JSON to XML
Serialize JSON as XML via fast-xml-parser. Mirrors xml-to-json — keys prefixed with @_ become attributes, the special key #text becomes the element text content. Round-trip with xml-to-json on simple shapes.
About JSON to XML
JSON to XML serializes a JSON object as XML using fast-xml-parser, mirroring the xml-to-json conversion so the two round-trip on simple shapes. Keys prefixed with @_ become attributes and a special #text key becomes element text content, giving you control over the resulting markup. Reach for it when a legacy system or SOAP endpoint expects XML, and run it all in your browser without uploading anything.
- Category
- convert
- Input
- Accepts: application/json or text/plain.
- Output
- Outputs: application/xml.
- Cost
- Free, runs in your browser
- Memory
- low
Common uses
- Producing an XML request body for a SOAP service that only accepts XML
- Converting JSON config into an XML format a legacy application still requires
- Emitting attributes by prefixing keys with @_ so the XML matches a target schema
- Setting element text content via the #text key when an element also needs attributes
- Round-tripping data back to XML after editing it as JSON with xml-to-json
- Generating sample XML payloads from JSON fixtures for integration testing
Frequently asked questions
What input does it take?
JSON as application/json or plain text. The output is XML.
How do I produce attributes?
Prefix the JSON key with @_ and it becomes an XML attribute, mirroring how xml-to-json represents attributes.
How do I set an element's text when it also has attributes?
Use the special #text key for the text content alongside the @_ attribute keys.
Is my JSON uploaded?
No. Serialization runs locally in your browser via fast-xml-parser.
Will it round-trip perfectly with xml-to-json?
On simple shapes, yes. Very complex XML features like namespaces and mixed content may not survive a full round trip.
Keywords
- xml
- json
- convert
- serialize
- soap