XML to JSON Converter

XML input

No XML yet

Paste XML on the left to see it converted to JSON here.

APIMock teamUpdated

In short: a free, 100% client-side XML to JSON converter that parses your XML in a background worker and renders the result in an interactive JSON tree view, with dual-mode search, a local saved-snippet history, copy, download, and a full set of keyboard shortcuts. Everything runs in your browser, so your data never touches a server — safe for API payloads, SOAP responses, and config files.

It's built for developers who work with XML APIs, RSS/Atom feeds, SOAP envelopes, and configuration files. Paste raw XML and it is parsed in a background Web Worker and rendered as a navigable JSON tree, without uploading a single byte.

How to convert XML to JSON

  1. 1Paste your XML. Paste an XML document, SOAP envelope or RSS/Atom feed into the XML input pane.
  2. 2Check for errors. The XML is checked for well-formedness half a second after you stop typing. Unclosed or mismatched tags show an error with its line number.
  3. 3Explore the JSON. The converted JSON appears in an interactive tree, with attributes prefixed @_ and repeated tags grouped into arrays.
  4. 4Copy or download the JSON. Copy any node as JSON, or download the full result as converted.json.

How XML to JSON conversion works

  • Attributes are preserved: XML attributes are kept and prefixed with @_ so they never clash with child element names (for example <note id="1"> becomes { "note": { "@_id": "1" } }).
  • Repeated tags become arrays: When the same element appears multiple times in a parent, those tags collapse into a JSON array; a single occurrence stays a plain value.
  • Text next to attributes goes under #text: An element with both attributes and text keeps the text under a #text key.
  • Numbers and booleans are typed: Element text like 2 or true becomes a JSON number or boolean, so 007 becomes 7. Attribute values stay strings.
  • Well-formedness validation: Mismatched or unclosed tags surface a clear error message and line number instead of silently producing wrong JSON.
  • Non-blocking parsing: Conversion runs in a background Web Worker, so even large feeds and API dumps don't freeze the page.

XML to JSON example

An order with attributes, a repeated <item> tag and a text value next to an attribute converts like this:

XML input
<order id="A-1001" status="paid">
  <customer>Ada Lovelace</customer>
  <item sku="KB-01">
    <name>Keyboard</name>
    <qty>1</qty>
  </item>
  <item sku="MS-02">
    <name>Mouse</name>
    <qty>2</qty>
  </item>
  <total currency="USD">89.50</total>
</order>
JSON output
{
  "order": {
    "customer": "Ada Lovelace",
    "item": [
      { "name": "Keyboard", "qty": 1, "@_sku": "KB-01" },
      { "name": "Mouse", "qty": 2, "@_sku": "MS-02" }
    ],
    "total": { "#text": 89.5, "@_currency": "USD" },
    "@_id": "A-1001",
    "@_status": "paid"
  }
}

Explore the JSON in an interactive tree

  • Collapsible tree view: Navigate deeply nested converted structures with collapsible nodes and color-coded syntax highlighting.
  • Expand all / collapse all: Open the entire structure or fold it back to the top level in one click (or one shortcut).
  • Full-width mode: Hide the raw XML input and give the JSON tree the whole width when you're reading large documents.

Search, save, copy and export

  • Two search modes: Filter mode shows only matching nodes and their parents; highlight mode keeps the full tree and steps through matches with next/previous.
  • Local saved history: Save XML snapshots and reopen them later — renamed, pinned, and persisted in your browser, kept separate from the JSON formatter's history.
  • Copy & download as JSON: Copy any node, or download the full converted JSON to a .json file with one click.
  • Dark & light themes: Switch themes manually or follow your system preference; your choice is remembered.

Keyboard shortcuts

Every action has a keyboard shortcut, and each button's tooltip shows it. Shortcuts use Cmd on macOS and Ctrl on Windows and Linux.

ActionShortcut
Open search (raw input or tree)Ctrl + F
Toggle filter / highlight search modeCtrl + Shift + F
Download converted JSONCtrl + S
Copy raw inputCtrl + Shift + S
Save to historyCtrl + Shift + H
Expand all nodesCtrl + Shift + E
Collapse all nodesCtrl + Shift + L
Toggle full-width treeCtrl + Shift + X
Toggle dark / light themeCtrl + Shift + D
Clear the editorCtrl + Shift + Backspace
Close searchEsc

Frequently asked questions

How do I convert XML to JSON online?

Paste your XML document into the left pane. The tool parses it in a background Web Worker and instantly renders the equivalent JSON in the interactive tree view — no upload, no sign-up. You can then copy the JSON or download it as a .json file.

Is this XML to JSON converter safe for sensitive data?

Yes. All parsing and conversion happen entirely in your browser using JavaScript. Your XML never leaves your device or reaches any server, so it is safe for API payloads, SOAP responses, configuration files, and feeds that contain tokens or private data.

How are XML attributes represented in the JSON output?

Attributes are preserved and prefixed with "@_" so they never collide with child element names. For example, <note id="1"> becomes { "note": { "@_id": "1" } }, keeping the attribute data intact alongside the element's children.

How are repeated XML tags handled?

When an element appears more than once inside the same parent, those repeated tags are collapsed into a JSON array. For example two <item> elements become "item": [ … , … ]. A single occurrence stays a plain object/value, matching how most XML-to-JSON conventions work.

What happens to an element's text when it also has attributes?

The text goes under a "#text" key next to the attributes. For example <total currency="USD">89.50</total> becomes "total": { "#text": 89.5, "@_currency": "USD" }. An element with text and no attributes becomes a plain value.

Are numbers and booleans converted, or kept as strings?

Element text that looks like a number or boolean is converted: <qty>2</qty> becomes 2 and <active>true</active> becomes true. That means formatting is normalised, so 89.50 becomes 89.5 and 007 becomes 7 — watch out for zip codes, phone numbers and IDs with leading zeros. Numbers too large to represent exactly stay strings, and attribute values are always kept as strings.

Why does my XML show a parse error?

The converter validates well-formedness: every opening tag needs a matching closing tag, attributes must be quoted, and there must be a single root element. If a tag is unclosed or mismatched (for example <a><b></a>), the error message and its line number are shown so you can fix the markup.

Can I convert large XML files without freezing the browser?

Yes. Parsing runs in a background Web Worker separate from the interface thread, so large feeds and API responses do not lock up the page. The resulting JSON tree starts partially collapsed, so you expand only the branches you need.

What is the difference between XML and JSON?

XML is a markup language that wraps data in nested tags and supports attributes, namespaces, and mixed content. JSON is a lighter data-interchange format built from objects, arrays, strings, numbers, and booleans. JSON is easier for JavaScript and most modern APIs to consume, which is why converting XML to JSON is a common task.

Are my converted snippets kept private?

Yes. Saved history lives only in your browser's local storage on this device, and the XML converter keeps its own separate history from the JSON formatter. You can rename, pin, and delete entries; nothing is uploaded or synced. Clearing your browser data removes them.

Related tools and guides