XML → JSON

About the XML → JSON playground

The XML → JSON tool parses XML markup and produces an equivalent JSON object, turning elements into keys, nested elements into nested objects, and repeated sibling elements into arrays. Attributes and text content are mapped using consistent conventions. This is useful when consuming XML feeds, SOAP responses, or legacy data in modern JavaScript applications that work most naturally with JSON.

XML is a verbose, tag-based markup language with elements, attributes, namespaces, and a single root, while JSON is a concise format built from objects, arrays, and primitive values. Because XML carries information that JSON lacks a direct slot for — attributes versus child text, for example — converters adopt conventions such as prefixing attribute keys, so the resulting JSON faithfully reflects the original document's structure.

HostedXML → JSON runtime
mainentry file
single fileworkspace
stdinprogram input

How it works

1

Write

The main file is the entry point for each run.

2

Give it input

Use the Input panel to pipe standard input to your program when it needs data.

3

Run

Run sends your code to a fresh hosted runtime and streams the result into the output panel.

4

Keep or share

Your draft stays in this browser, and Share creates a separate snapshot link.

External resources

  • w3.org/XML— Official website

Input (XML)

<user id="1">
  <name>Ada</name>
  <active>true</active>
</user>

Output (JSON)

{
  "user": {
    "@id": "1",
    "name": "Ada",
    "active": "true"
  }
}

Input (repeated elements)

<list>
  <item>a</item>
  <item>b</item>
</list>

Output (JSON)

{
  "list": {
    "item": ["a", "b"]
  }
}

Input (nested elements)

<order>
  <id>7</id>
  <customer>
    <name>Ada</name>
  </customer>
</order>

Output (JSON)

{
  "order": {
    "id": "7",
    "customer": {
      "name": "Ada"
    }
  }
}

Input (attribute + text)

<price currency="USD">9.99</price>

Output (JSON)

{
  "price": {
    "@currency": "USD",
    "#text": "9.99"
  }
}

Input (empty element)

<config>
  <flag/>
  <name>app</name>
</config>

Output (JSON)

{
  "config": {
    "flag": null,
    "name": "app"
  }
}

Input (entity in text)

<note>
  <text>Ben &amp; Jerry</text>
</note>

Output (JSON)

{
  "note": {
    "text": "Ben & Jerry"
  }
}

Input (repeated objects)

<users>
  <user><name>Ada</name></user>
  <user><name>Linus</name></user>
</users>

Output (JSON)

{
  "users": {
    "user": [
      { "name": "Ada" },
      { "name": "Linus" }
    ]
  }
}

How it works

The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.

What it does

Paste XML markup and get an equivalent JSON object back.

Elements become keys and nested elements become nested objects.

Repeated sibling elements collapse into JSON arrays.

Attributes and text

Attributes are mapped using a consistent prefix so they aren't confused with child elements.

Element text content is placed into its own conventional key.

Namespaces and the single root are reflected in the resulting structure.

When to use it

Consuming XML feeds or SOAP responses in JavaScript apps that prefer JSON.

Bringing legacy XML data into a modern JSON workflow.

Privacy

Parsing runs locally in your browser — your XML never reaches a server.

Suitable for confidential SOAP or feed payloads.

Every shortcut, searchable:

Editing

Undo
Ctrl+Z
Redo
Ctrl+⇧+Z
Select next occurrence
Ctrl+D
Delete line
Ctrl+⇧+K
Move line up / down
Alt+↑ / ↓
Copy line up / down
Alt+⇧+↑ / ↓
Toggle comment
Ctrl+/
Indent line
Ctrl+]
Outdent line
Ctrl+[

Navigation

Find
Ctrl+F
Find & replace
Ctrl+H
Go to line
Ctrl+G
Go to symbol
Ctrl+⇧+O

Selection

Select all
Ctrl+A
Select line
Ctrl+L
Select all occurrences
Ctrl+⇧+L
Shortcuts follow your OS — ⌘ becomes Ctrl on Windows and Linux.
It parses an XML document and converts it into a JSON object, mapping elements to keys, repeated elements to arrays, and attributes to prefixed keys.
No. Parsing and conversion happen entirely in your browser, so your XML is never sent to a server.
Yes, it is free with no registration or usage limits.
Attributes are typically placed into the element's object under a prefixed key, such as @id, so they remain distinct from child elements and text content.
XML text content has no inherent data type, so values like 1 or true are converted as strings unless you explicitly cast them afterward.
xml
json

Output

JSON output

>_compilebytes

A fast place to write code and run it in isolated hosted runtimes. Free, forever.

Playgrounds

Python compilerC compilerJavaScript compilerC++ compilerTypeScript compilerGo compilerJava compilerRust compiler
All playgrounds →

Tools

JSON formatterRegex testerBase64 encoderJWT decoder
JSON formatterBase64 encoder & decoderRegex testerJWT decoder
All tools →

Company

TermsPrivacy[email protected]
© 2026 compilebytes115 runtimes · no signup115 runtimes · isolated sandboxes · no signup