Skip to main content
PulsarKit

Convert JSON to XML

Build a valid XML document from JSON: you name the root and item tags, and keys XML cannot accept are repaired rather than dropped.

Drop your files here

.json, .ndjson, .txt · up to 300 MB

More settings

How to Convert to XML

  1. 1

    Drop a JSON file

    Add one file or up to twenty. The text is read and parsed inside this browser tab, and a syntax error names the exact line and column.

  2. 2

    Name the root and item tags

    The root wraps the whole document; the item name is reused for every entry of an array. Keys that start with the attribute prefix become attributes.

  3. 3

    Convert and download the XML

    Press the button to get a declared, indented document. A batch comes back as one ZIP archive.

Keys XML will not accept as tag names

JSON object keys are almost unrestricted; XML element names are not. “2024 sales”, “order id” and the empty string are all legal keys, and none of them can be written as a tag. Silently dropping those fields would lose data, so invalid characters become underscores, a name starting with a digit gets an n in front, and the full was-to-became list is handed back with the result.

Characters XML forbids outright

Escaping takes care of ampersands and angle brackets. Control characters below 0x20 are a different problem: XML 1.0 rejects them no matter how they are written, and neither an entity nor a CDATA block rescues them. One stray 0x0B pasted in from a spreadsheet cell would make the whole document unparseable, so those bytes are stripped and counted, with the count shown beside the result.

Attributes, text nodes and nulls

A key beginning with the attribute prefix, @_ by default, becomes an attribute of its parent instead of a child element, and the text key carries the element's own text. JSON has null and XML has no equivalent, so the choice is yours: an empty element, an element marked with xsi:nil, or no element at all.

The file never leaves this tab

Reading the file, parsing the JSON, repairing names and serializing the XML all happen in your browser, in a worker thread, using code that shipped with the page. There is no upload step, no processing queue and no account. Close the tab and the file is gone, because no copy of it was ever made anywhere else.

Frequently asked questions

How do I set the root element name?

The root name is the first field on the page and defaults to root. It has to be a legal XML name (letters, digits, dots, hyphens and underscores, not starting with a digit or with the reserved prefix xml), and you are told immediately if it is not, with a suggested fix.

How do I turn a JSON key into an XML attribute?

Prefix the key in your JSON with @_ and it becomes an attribute of the enclosing element rather than a nested tag. The prefix is configurable up to three characters, and clearing it disables attribute mapping entirely, so every key becomes an element.

What happens to keys that are not valid XML tag names?

By default they are repaired: illegal characters turn into underscores, a leading digit gets an n prefix, and an empty key falls back to the item name. You get a warning listing what was renamed. You can also force every fix through silently, or stop with an error on the first bad key instead.

What happens to null values?

Three options. An empty element keeps the field visible in the document, xsi:nil marks it as explicitly null in the way schema-aware consumers expect and declares the namespace on the root, and skipping leaves the field out. Empty elements are the default because they round-trip most predictably.

When do I need CDATA?

Rarely, since ordinary escaping is always correct. CDATA is mostly for readability when values contain a lot of markup-like text: turn it on and strings over 200 characters, or strings containing angle brackets and ampersands, go into a CDATA block. A literal ]]> inside such a value is split across two blocks so the output stays valid.

Is the order of keys preserved?

Yes. Elements are written in the order the keys appear in the source JSON, and array entries keep their index order. Attributes are written before child elements because XML requires it, but among themselves they also follow source order, which keeps output stable enough to diff between runs.

Does my file get uploaded anywhere?

No. Everything happens in your browser tab, and the JSON parser and XML serializer are part of the page rather than a service somewhere. There is no server that could receive the file, so nothing is stored, logged or retained after you close the tab.

Related tools