Conversor de XML a JSON gratuito
El Conversor de XML a JSON convierte documentos XML en JSON limpio. Los atributos, los elementos anidados y las etiquetas repetidas se manejan para que los arrays y los objetos salgan como esperarías.
The reverse direction is not a direct conversion, but the JSON Formatter & Beautifier makes the result readable and the JSON Validator confirms it parses. For XML that is markup rather than data, the XML Formatter & Beautifier is the tool.
Cómo usar XML a JSON
- 1 Paste your XML.
- 2 Convert. Elements become keys, attributes are handled according to the setting you choose.
- 3 Check how repeated elements were represented, since the choice affects everything downstream.
- 4 Copy the JSON.
Cómo usarlo
Pega tu XML y haz clic en Convertir. El JSON aparece a la derecha, con formato legible y listo para usar.
- Los atributos se conservan bajo un prefijo @
- Los elementos repetidos se convierten en arrays
- El contenido de texto se coloca bajo #text cuando se mezcla con atributos
- Informa de XML mal formado con un mensaje claro
- Se ejecuta enteramente en tu navegador
Preguntas frecuentes
How are attributes and text content represented?
There is no standard, so the convention has to be chosen. Attributes are commonly prefixed to distinguish them from child elements, or nested under a dedicated key. Mixed content — text and elements together inside one element — is the genuinely hard case, because JSON has no equivalent and the text has to be given a key.
What happens with repeated sibling elements?
They become an array, which is usually what you want. The ambiguity is when there is only one instance: it is impossible to know whether the schema allows more, so a naïve converter produces an object for one and an array for many. That inconsistency breaks consumers, and the usual fix is a setting that always uses arrays for such elements.
Why does the order of elements change?
Because JSON objects are formally unordered, so element order cannot be preserved in the general case. If order carries meaning in the source — as it does in a document rather than a data file — the conversion loses information that no amount of care can retain.
Herramientas para desarrolladores relacionadas
También te puede interesar
Herramientas de otras categorías que suelen combinarse con XML a JSON: