DevMate
Back to Toolverse

Converters

XML ↔ JSON Converter

Convert XML to a documented JSON mapping and build XML from a single-root JSON object. Check attributes, repeated children, string values, and round-trip limits.

Local processing
Loading tool workspace...

About this tool

When to use it

Convert XML to a documented JSON mapping and build XML from a single-root JSON object. Check attributes, repeated children, string values, and round-trip limits.

How to use it

Use this pair to inspect an XML response as JSON or build a simple XML fixture from a compatible object. Choose the direction before pasting, convert, and inspect attributes and repeated children. Switching direction loads an example rather than carrying over the last result. Download or share only after checking that the receiving system expects this mapping.

Guide updated . Examples checked against this implementation.

Worked examples

XML to JSON: an attributed job with two steps

Input

<job id="007"><step>build</step><step>deploy</step></job>

Expected output

{
  "job": {
    "step": [
      "build",
      "deploy"
    ],
    "@_id": "007"
  }
}

The attribute becomes @_id. Repeated step elements become an array; the identifier stays the string 007 rather than becoming the number 7.

JSON to XML: rebuild the fixture

Input

{"job":{"@_id":"007","step":["build","deploy"]}}

Expected output

<?xml version="1.0" encoding="UTF-8"?>
<job id="007">
  <step>build</step>
  <step>deploy</step>
</job>

The root property names the enclosing element. Arrays inside it create repeated child elements. Output includes an XML declaration and a final newline.

Errors and unsupported input

<job><step>build</job>

Close step before closing job. The parser reports the malformed XML location; copy the complete document and retry.

{"job":["build","deploy"]}

Put the repeated values inside one enclosing root, for example {"job":{"step":["build","deploy"]}}. A root array would create multiple document elements and is rejected.

Continue this workflow

Format references

Questions

Frequently asked questions

How are XML attributes and repeated elements represented?

Attributes use @_ keys and repeated sibling elements become arrays. Text alongside attributes or children can use #text.

Why does JSON-to-XML require one root property?

An XML document needs one enclosing element. Use one named root with repeated elements inside it; a top-level array value would create multiple roots.