⚡
usefultools.dev
X⇄J

XML to JSON Converter – and JSON to XML

NOVO

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.

Funciona 100% no seu navegador — o que você insere nunca é enviado nem armazenado nos nossos servidores.

Esta ferramenta ainda não está totalmente traduzida, por isso parte do texto continua em inglês. A ferramenta funciona da mesma forma em todos os idiomas.

⚡

Exemplos rápidos

Entradas típicas e os resultados que esta ferramenta gera.

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>
📖

Visão geral

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.

Por que usar esta ferramenta?

  • 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
⭐

Recursos

🔁

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.

🛠️

Como usar

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.

🤔

Perguntas frequentes