Skip to content

XML to JSON Converter

Convert XML documents to JSON format instantly in your browser. Handles nested elements, repeated child tags (converted to arrays), and custom indent styles.

Paste your XML document to convert it to JSON

JSON Output
{ "person": { "name": "Alice", "age": 30 } }
Lines
6
Characters
56
JSON Output
{
  "person": {
    "name": "Alice",
    "age": 30
  }
}

Como funciona

Fórmula

DOMParser → recursive node traversal → JSON.stringify

Exemplo prático

<person><name>Alice</name><age>30</age></person> converts to {"person":{"name":"Alice","age":30}}

XML to JSON Conversion Rules

This converter applies the following standard rules when translating XML to JSON:

XML FeatureJSON Representation
Element with text"tagName": "textValue"
Nested element"tagName": { ... }
Repeated same-name elements"tagName": [ ... ] (array)
Empty element <tag/>"tagName": null
Numeric text contentJSON number (e.g., 30)
Boolean text contentJSON boolean (true / false)

The root XML element becomes the top-level key in the output JSON object. The entire output is valid, standards-compliant JSON ready for consumption by any programming language.

Perguntas frequentes

How are repeated XML elements handled?

When the same tag name appears more than once under a parent element, all instances are grouped into a JSON array. For example, multiple <item> tags become an array under the 'item' key.

What happens to XML attributes?

This converter focuses on element content and child elements. XML attributes are not currently included in the JSON output. Use the element-based approach for maximum compatibility.

Are numeric and boolean values detected?

Yes. Text content that parses as a valid number (e.g. '30') is converted to a JSON number. 'true' and 'false' text content is converted to JSON booleans.

Is the conversion reversible (XML → JSON → XML)?

Mostly yes for simple structures. Complex XML with attributes, mixed content, or XML namespaces may not round-trip perfectly, as these features have no direct JSON equivalent.

Última atualização: 19 de mar. de 2026
datas e tempo

Contador De Dias Calculator

pt-BR: dias entre duas datas (incluir ultimo dia), dias ate uma data futura (contagem regressiva), somar/subtrair dias.

datas e tempo

Calculadora De Horas Trabalhadas Calculator

pt-BR: rows of entrada, saida, intervalo -> horas do dia; week/month total; hora extra above jornada (default 8h/44h); output hh:mm and decimal.

datas e tempo

Calculadora Entre Datas Calculator

pt-BR: diferenca entre duas datas in anos/meses/dias, total dias/semanas/meses; adicionar/subtrair periodo.

financas

Calculadora De Investimentos Calculator

pt-BR: aporte inicial, aporte mensal, taxa (a.a. or a.m. toggle), prazo -> montante = FV with contributions; optional IR regressivo (22.5% up to 180d, 20% 181-360d, 17.5% 361-720d, 15% >720d); CDI/Selic/poupanca reference rates come from data/rates.json and are editable, never hard-coded.

saude

Calculadora De Pace Calculator

Same logic as pace calculator, native pt-BR UI/copy: ritmo por km/milha, provas (5K,10K,21K,42K).