⚡
usefultools.dev
X⇄J

XML to JSON Converter – and JSON to XML

NOUVEAU

XML to JSON converter that maps attributes to "@name", text to "#text" and repeated tags to arrays, and converts JSON back to XML. Free, runs in your browser.

Fonctionne à 100 % dans votre navigateur — vos données ne sont jamais envoyées ni stockées sur nos serveurs.

Cet outil n'est pas encore entièrement traduit : une partie du texte est encore en anglais. L'outil lui-même fonctionne de la même façon dans toutes les langues.

⚡

Exemples rapides

Des entrées typiques et les résultats produits par cet outil.

Number
<age>42</age>
{"age":42}
Attribute
<a id="7">x</a>
{"a":{"@id":7,"#text":"x"}}
Array
<l><i>1</i><i>2</i></l>
{"l":{"i":[1,2]}}
JSON to XML
{"a":{"@id":"7"}}
<a id="7"/>
Root
{"x":1,"y":2}
<root><x>1</x><y>2</y></root>
📖

Présentation

This XML to JSON converter turns an XML document into JSON you can use in JavaScript, Python or a REST API, and converts JSON back into XML. It uses a common, reversible convention: attributes become keys starting with @, element text becomes #text when the element also has attributes, and elements that repeat become arrays.

Developers use it to inspect SOAP or RSS responses, migrate XML config to JSON, and build XML request bodies from JSON fixtures. Tick Always use arrays when your code expects a list even for a single child, and untick number detection to keep every value as a string, for example to protect postcodes like 007.

The XML is parsed by a strict parser in your browser, so errors come with line and column. CDATA is read as text, comments and processing instructions are skipped. Nothing is uploaded.

Pourquoi utiliser cet outil ?

  • Two-way: XML to JSON and JSON to XML
  • Predictable @attribute and #text mapping
  • Repeated elements become proper arrays
  • Clear errors with line and column
  • Private, no upload or sign-up
⭐

Fonctionnalités

🔁

Both directions

Convert XML to JSON or JSON to XML, and feed the output back in with one click.

🏷️

Attribute mapping

Attributes become "@name" keys and mixed text becomes "#text", and the reverse direction reads them the same way.

📚

Array control

Repeated children become arrays automatically, or every child becomes an array with Always use arrays.

🔢

Type detection

Numbers and true/false become JSON numbers and booleans; turn it off to keep strings.

🌱

Root name

Pick the root element used when the JSON has several top-level keys or is an array.

📍

Precise errors

Malformed XML or JSON is reported with the exact line and column.

🛠️

Mode d'emploi

1

Choose a direction

Select XML → JSON or JSON → XML at the top.

2

Paste your data

Paste the document into the input box, or press Sample.

3

Adjust options

Set arrays, type detection and indent, or the root name and XML declaration.

4

Copy the output

Press Copy or Download, or Use output as input to convert back.

🤔

Questions fréquentes