jfmt.dev

JSON to XML

Paste JSON on the left and copy XML on the right. Objects become elements, arrays repeat children, and keys that start with @_ become attributes. Built for configs, SOAP snippets, and feeds that still want XML.

input.json

JSON formatter

Input0 B
Output · preview.json
{ }

Run a tool to see a polished result here

Live syncReady · processed locally in your browser
Local-only processing: your JSON never leaves this browser tab.

How JSON shapes map onto XML

A JSON object is an element with child elements named after its keys. A JSON array repeats the child element (or a wrapper) once per item. Strings, numbers, booleans, and null become text nodes. Invalid JSON is rejected before any XML is emitted. XML-to-JSON lives in the same sidebar if you need the opposite direction.

How XML attributes map from JSON

The builder treats keys that start with @_ as attributes of the parent element, using the name after the prefix. `"note": { "@_priority": "high", "to": "dev" }` becomes `<note priority="high"><to>dev</to></note>`. A key named `priority` without the prefix becomes a child element `<priority>`. If you need namespaces, put the xmlns declaration on @_xmlns (or a similarly prefixed key) rather than hoping the converter infers one.

{ "note": { "@_priority": "high", "to": "dev" } }
→ <note priority="high">
    <to>dev</to>
  </note>

Arrays, mixed types, and invalid element names

JSON arrays do not have a tag name of their own. The converter repeats the parent’s child node. Mixed arrays (`[1, {"n":2}]`) produce mixed children and are legal XML but painful to schema. JSON keys with spaces or leading digits are not legal XML names; rename them before converting or expect the builder to emit a name you will have to fix. Booleans become the text `true`/`false`, not `1`/`0`.

XML is a tree; CSV is a grid

If the reason you opened this page is “I want to open JSON in Excel”, you are on the wrong converter. XML preserves nesting. CSV and Excel flatten it. Keep JSON to XML for hierarchical documents, and use JSON to CSV / JSON to Excel when each object should be a row.

Sample input on this page

The sample is a `note` object with `@_priority`, `to`, `from`, and `body`. After conversion you should see a `<note priority="high">` element with three child elements. Change `@_priority` to `priority` if you would rather have a child element than an attribute.

{
  "note": {
    "@_priority": "high",
    "to": "dev",
    "from": "jfmt",
    "body": "local conversion"
  }
}

How to use this tool

  1. Paste a JSON object. A single root key (for example `note`) makes the XML easier to read than a bag of top-level keys.
  2. Prefix a key with @_ when it should be an XML attribute (`"@_priority": "high"` → `priority="high"` on the parent).
  3. Run JSON to XML and copy the markup. Arrays of scalars become repeated elements with the same tag name.
  4. If you needed a spreadsheet instead of markup, use JSON to CSV or JSON to Excel — XML is a tree, not a grid.

When this page is the right choice

Use JSON to XML when a downstream system still speaks XML: SOAP bodies, RSS-like feeds, Android-style resource files, or an enterprise bus. Do not use it as a pretty-printer for JSON, and do not use it when the output has to be columns in Excel.

FAQ

Are XML attributes supported?

Yes. Prefix a key with @_ (`@_id`, `@_priority`) and it is emitted as an attribute on the parent element.

What happens to JSON arrays?

Array items become repeated child elements. There is no automatic wrapper tag named `item` unless you add that key yourself.

Is XML-to-JSON on this page?

This URL starts in JSON→XML. Switch the sidebar to convert the other way without leaving the editor.

Will invalid XML names be rewritten?

Keys should already be legal XML names. Spaces and leading digits are the usual failures — rename those keys in JSON first.

Is my file uploaded?

No. Conversion runs in the browser.