JSON para XML
Converta estruturas de dados JSON em XML bem formatado.
Roda no seu navegador; seus dados nunca saem do seu dispositivoGrátis, sem cadastro
XML output
The converted XML will appear here.
Como funciona
The input is first parsed as JSON with precise error reporting. The value is then serialized as XML using the fast-xml-parser library, a real, widely used XML implementation: nested objects become elements, arrays become repeated elements, and @-prefixed keys become attributes.
The generated XML is validated before it is shown, so illegal element names surface as errors rather than broken output.
Recursos
- Attribute and text-node support (@keys and #text)
- Arrays as repeated elements
- Sensible root element handling, wrapping when needed
- Optional XML declaration, 2 or 4 space indentation
- Output validated, JSON errors reported with line/column
- 100% client-side, nothing leaves your browser
Como usar
- Paste JSON, or upload a .json file.
- Choose indentation and whether to include the
<?xml?>declaration. - Press Convert to XML, then copy the result or download it as a .xml file.
Exemplo
JSON:
{"deployment": {"name": "app", "replicas": 4}}
XML:
<deployment>
<name>app</name>
<replicas>4</replicas>
</deployment>Perguntas frequentes
- How does the converter decide on the root element?
- XML requires exactly one root element. If your JSON is an object with a single key whose value is not an array, that key becomes the root: {"deployment": {…}} becomes <deployment>…</deployment>. Any other object is wrapped in a <root> element, and a top-level array becomes repeated <item> elements inside <root>, since XML has no bare top-level array.
- How do I create XML attributes?
- Use keys starting with @ in your JSON, and #text for an element's text content. For example, {"a": {"@_id": "1", "#text": "hi"}} produces <a id="1">hi</a>. This is the standard convention used by the underlying fast-xml-parser library.
- What happens to arrays?
- Arrays become repeated elements: {"ports": [8080, 8443]} produces <ports>8080</ports><ports>8443</ports>. Note the asymmetry when converting back: a single-element array produces one element, which parses back as a plain value rather than an array.
- Is the generated XML validated?
- Yes. The output is run through an XML validator before you see it, so JSON keys that are not legal XML element names (containing spaces, "<", or starting with a digit) produce a clear error instead of silently broken XML.
- What happens if my JSON is invalid?
- You get a clear error message with the line and column where the JSON parser failed. Nothing is converted until the input parses.
- Is my data sent to a server?
- No. Conversion happens entirely in your browser with JavaScript. Nothing you type or paste is transmitted anywhere; you can verify this in your browser's network inspector.