DevNet KitTHE EVERYDAY TOOLBENCH
Code & Data · Local-first

XML ↔ JSON Converter Online

Convert XML and JSON with explicit attributes, repeated nodes and text values.

Open XML ↔ JSON Converter

Free · No sign-up · Browser-based processing

What XML ↔ JSON Converter does

Convert well-formed XML into an explicit JSON representation, or turn that representation back into XML. Attributes use @ prefixes, repeated child elements become arrays and mixed text uses #text. Text values remain strings to avoid changing identifiers, dates or leading-zero numbers. This representation is intended for inspection, not a lossless XML round trip.

Common uses

  • Inspect XML API responses
  • Convert repeated XML records for debugging

How to use XML ↔ JSON Converter

  1. Paste a complete XML document with a single root element and choose to-json.
  2. For to-xml, paste JSON with exactly one root property. Use @name for attributes and arrays for repeated elements.
  3. Review attributes, arrays and #text before using the result in an application.

Privacy: Runs locally in your browser. Input is not uploaded to the DevNet Kit server.

XML ↔ JSON Converter example

Try the tool with this representative input:

<catalog><book id="1"><title>Network Design</title></book><book id="2"><title>API Design</title></book></catalog>

Options

to-json

Expected result

The catalog.book property is an array of two records with @id and title fields.

XML ↔ JSON Converter FAQ

How are attributes represented?

An attribute such as id="1" becomes an @id property with a string value.

Are namespaces or mixed-content order preserved?

Qualified names are kept, but mixed-content ordering and XML formatting are not preserved. DTD and entity declarations are rejected.

Which JSON keys can be converted back to XML?

Use simple element names, @name attributes and #text values. Qualified namespace names are accepted when reading XML but are not generated in reverse mode. Mixed-content order is not preserved.

Convert XML attributes and repeated elements into JSON

Choose to-json and paste one well-formed XML document. Attributes become keys beginning with @, while repeated sibling elements become arrays. Text stays as strings, which helps preserve identifiers such as 001.

Choose to-xml to convert the same JSON representation back with one root property. This mapping does not preserve mixed-content order, comments or original formatting; it is intended for data inspection rather than archival XML round trips.

Worked example

Input and settings:

<items><item id="001">Ada</item><item id="002">Linus</item></items>

Expected result or interpretation:

{"items":{"item":[{"@id":"001","#text":"Ada"},{"@id":"002","#text":"Linus"}]}}

Questions about this workflow

Why does an XML attribute become @id in JSON?

The @ prefix distinguishes attributes from child elements. For example, <item id="001">Ada</item> maps to an object with @id and #text string values.

Can I convert an XML fragment with multiple roots?

Wrap the fragment in one root element before converting. A complete XML document needs a single root; the reverse direction also expects one root property.

Continue this workflow