JavaScript to XML Converter
Paste a JavaScript object, class, or instance. Get clean XML back.
What this tool does
If you have ever had to hand-craft an XML payload to match a JavaScript object — for a SOAP service, an RSS feed, a sitemap, or a test fixture — you know the pain. XMLSerializer needs a DOM, DOMParser goes the other direction, and building elements by hand means you forget a child the first three times. Paste the JS here instead and get back well-formed XML in one pass. Works for a plain object, an ES6 class plus new instance, or anything deeply nested.
It understands how JS values actually map to XML. Numbers and booleans become their string form. Date objects come out as ISO-8601. BigInt is emitted as its decimal string (without the n suffix). null and undefined fields become empty elements instead of being dropped, so the output shape stays stable. Arrays become container elements with one child per item, named after the parent key singularised — an items array on Order becomes <items><item>...</item></items> unless the array contains typed class instances, in which case the class name is used.
Class definitions are handled too. A class Order { constructor(...) { this.x = ...; } } plus const order = new Order(...) gives you an <Order> root with every property that got assigned in the constructor. Nested class instances expand as nested elements. Methods, getters, symbol-keyed properties, and properties starting with # (private fields) are skipped. If you paste just a plain object literal, that object is serialized directly with a sensible root element name.
How to use it
Three steps. Works the same whether you paste a short literal or a whole module.
Paste your JavaScript (or try the sample)
Drop your JS into the left editor as-is. A plain object literal, an ES6 class + instance, a factory function return, or a Node.js module export — all fine. Click Load Sample to see a realistic Order / OrderItem / Address example.
Leave const, let, and import statements in. You do not need to strip them — the parser knows to ignore wrapping syntax and read the actual values.
Hit Convert
Click the green Convert button. The tool reads the JS, preserves every class, array, and nested object, and emits the XML in one pass. A short loading indicator shows while it runs.
Copy the XML
The right panel fills with indented, well-formed XML that any standards-compliant XML parser will accept. Copy it straight into your SOAP request, RSS template, or test fixture.
When this actually comes in handy
Building SOAP request bodies
You have a plain JS object that mirrors a SOAP request and need the XML body to drop into SoapUI, Postman, or a <code>fetch</code> call. Paste the object, copy the XML, move on.
Generating RSS and Atom feeds
Turn a feed object with title, link, and items into a well-formed <a href="https://www.w3.org/TR/xml/" target="_blank" rel="noopener">XML</a> skeleton you can wrap in the proper RSS envelope — no handwritten element building.
Starting sitemap.xml files
Paste an array of URL objects and get the scaffolding you need for a <code><urlset></code> sitemap. Swap in the proper namespace and you are done.
Seeding integration tests
Convert the fixture objects from your Jest or Vitest setup into XML seed data for legacy systems, mock servers, or any consumer that still speaks XML.
Common questions
Does it work with plain objects, ES6 classes, and arrays?
Yes, all three. A plain object literal serializes directly with its keys as element names. An ES6 class plus a new instance uses the class name as the root element. Arrays become container elements with one child per item, named after either the element class (if the items are class instances) or the key singularised.
How does it handle Date, BigInt, and null?
Date objects come out as ISO-8601 strings. BigInt is emitted as its decimal string (the n suffix is dropped). null and undefined properties become empty elements (<field/>) rather than being silently skipped, so a downstream XSD that expects the element to be present still validates.
What about methods, getters, and private fields?
Methods and getters on a class are skipped — only data properties that actually got assigned on the instance are serialized. Private fields declared with #, symbol-keyed properties, and properties on the prototype (not the instance) are also skipped. This matches what JSON.stringify would do.
Can I paste just an object literal without a class?
Yes. A raw const data = { ... } works fine — the outer variable name is used as the root element, or a generic <root> if there is no binding. Nested objects and arrays inside expand as nested elements the same way.
Does it escape special characters like &, <, and >?
Yes. Text content containing &, <, >, ", or ' is escaped to the corresponding XML entities so the output always parses back cleanly. Unicode characters are kept as-is and the output is UTF-8.
Is my code stored?
Your code is sent to the backend for conversion and is not persisted — we do not log the payload. As always with online tools, if the code is genuinely sensitive, look it over before pasting.
Other tools you may need
JavaScript to XML is one piece of the puzzle. These pair well with it: