Paste XML and get clean JSON in one click — attributes, CDATA, namespaces and repeated elements are handled correctly. Nothing is uploaded, everything stays in your browser.
How to Convert XML to JSON
This XML to JSON converter turns any XML document into a clean, readable JSON object you can use in APIs, scripts or data pipelines. Paste your XML on the left — or open an .xml file directly from your computer — and element attributes become JSON keys, repeated elements are collected into arrays, and CDATA sections, entity references and self-closing tags are all handled correctly. Text-only elements become plain strings, empty elements become empty strings, and the root element's attributes and children become the top-level JSON keys. You can switch between 2 and 4 space indentation and optionally convert numeric and boolean text values to real JSON types so your data arrives ready to use. Everything runs in your browser: your data is never uploaded, and you can copy the JSON or download it as a .json file.
- Paste your XML on the left — or click Open .xml file to load a document from your computer. Load sample fills the editor with a realistic catalog example you can convert right away.
- The conversion runs automatically while you type or paste; the Convert button does the same on demand. Malformed input shows a clear inline error instead of broken output.
- Choose 2 or 4 spaces for the JSON indentation — the output re-renders immediately when you switch.
- Optional: enable Convert numbers & booleans so true, false, 249.90 or 1e5 become real JSON booleans and numbers instead of strings. Values with leading zeros or a bare decimal point stay strings.
- The JSON appears on the right, with a status line showing the root element and the output size in characters. Copy it to the clipboard or download it as converted.json.
Standards-aware conversion: text and attribute values are decoded following the XML 1.0 rules for entity and character references, while CDATA content stays 100% literal. Comments, processing instructions and whitespace-only text are removed during parsing, and the result is emitted with JSON.stringify, so the output is always valid JSON (RFC 8259). See the XML 1.0 specification and RFC 8259 for the underlying standards.
Frequently Asked Questions
Is my XML uploaded to a server?
No. The whole conversion runs in your browser: the XML is tokenized and parsed locally with JavaScript, and .xml files are read with the FileReader API. Nothing is transmitted, there is no account and no backend is involved.
How are attributes and repeated elements converted?
Attributes become JSON keys with an @ prefix (@id, @currency), so they can never collide with child element keys. Repeated sibling elements, for example several product tags, are collected into an array. Keys appear in document order.
Does it handle CDATA, entities and namespaces?
Yes. The standard XML entities and numeric character references are decoded in text and in attribute values. CDATA sections stay fully literal and are never decoded. Namespace prefixes such as ns:item or xmlns are preserved as plain names; the tool does not resolve namespaces.
What does the numbers and booleans option do?
When enabled, the text true or false becomes a real JSON boolean and numeric-looking text such as 249.90, 14 or 1e5 becomes a real number. Values with leading zeros (007) or a bare decimal point (.5) stay strings so no data is corrupted. Attribute values are converted the same way.
What happens to comments, whitespace and processing instructions?
Comments and processing instructions such as the XML declaration are removed, and whitespace-only text between elements is ignored, so the JSON contains only your data. The input must contain exactly one root element; its attributes and children become the top-level JSON keys, and the root name is shown in the status line.
XML in JSON umwandeln
Dieser XML-JSON-Konverter wandelt jedes XML-Dokument in ein sauberes, lesbares JSON-Objekt für APIs, Skripte oder Datenpipelines. Fügen Sie Ihr XML links ein — oder öffnen Sie eine .xml-Datei direkt von Ihrem Computer — und Element-Attribute werden zu JSON-Keys, wiederholte Elemente werden in Arrays gesammelt, und CDATA-Abschnitte, Entity-Referenzen und Self-Closing-Tags werden korrekt verarbeitet. Reine-Text-Elemente werden zu einfachen Strings, leere Elemente zu leeren Strings, und die Attribute und Kinder des Wurzelelements werden zu den obersten JSON-Keys. Sie können zwischen 2 und 4 Leerzeichen Einrückung wählen und optional numerische und boolesche Textwerte in echte JSON-Typen umwandeln, damit Ihre Daten sofort einsatzbereit sind. Alles läuft in Ihrem Browser: Ihre Daten werden niemals hochgeladen, und Sie können das JSON kopieren oder als .json-Datei herunterladen.
- Fügen Sie Ihr XML links ein — oder klicken Sie auf .xml-Datei öffnen, um ein Dokument von Ihrem Computer zu laden. Beispiel laden füllt den Editor mit einem realistischen Katalog-Beispiel, das Sie sofort umwandeln können.
- Die Umwandlung startet automatisch beim Tippen oder Einfügen; der Button Umwandeln löst sie auf Wunsch manuell aus. Fehlerhaftes XML zeigt eine klare Inline-Fehlermeldung statt kaputtem Ergebnis.
- Wählen Sie 2 oder 4 Leerzeichen für die JSON-Einrückung — die Ausgabe wird beim Umschalten sofort neu gerendert.
- Optional: Aktivieren Sie Zahlen & Booleans umwandeln, damit true, false, 249.90 oder 1e5 echte JSON-Booleans und -Zahlen statt Strings werden. Werte mit führenden Nullen oder nacktem Dezimalpunkt bleiben Strings.
- Das JSON erscheint rechts; die Statuszeile zeigt das Wurzelelement und die Ausgabegröße in Zeichen. Kopieren Sie das Ergebnis in die Zwischenablage oder laden Sie es als converted.json herunter.
Standardkonforme Umwandlung: Text- und Attributwerte werden nach den XML-1.0-Regeln für Entity- und Zeichenreferenzen dekodiert, CDATA-Inhalt bleibt zu 100 % literal. Kommentare, Processing Instructions und reine Leerraum-Texte werden beim Parsen entfernt, und das Ergebnis wird mit JSON.stringify erzeugt — die Ausgabe ist also immer gültiges JSON (RFC 8259). Siehe die XML-1.0-Spezifikation und RFC 8259 für die zugrunde liegenden Standards.
Häufig gestellte Fragen
Werden meine XML-Daten auf einen Server hochgeladen?
Nein. Die gesamte Umwandlung läuft in Ihrem Browser: Das XML wird lokal mit JavaScript tokenisiert und geparst, .xml-Dateien werden über die FileReader-API gelesen. Es wird nichts übertragen, es gibt kein Konto und kein Backend.
Wie werden Attribute und wiederholte Elemente umgewandelt?
Attribute werden zu JSON-Keys mit @-Präfix (@id, @currency) und können dadurch nie mit den Keys von Kind-Elementen kollidieren. Wiederholte Geschwister-Elemente, zum Beispiel mehrere product-Tags, werden in einem Array gesammelt. Keys erscheinen in Dokumentreihenfolge.
Werden CDATA, Entities und Namespaces unterstützt?
Ja. Die Standard-XML-Entities und numerischen Zeichenreferenzen werden in Texten und Attributwerten dekodiert. CDATA-Abschnitte bleiben vollständig literal und werden nie dekodiert. Namespace-Präfixe wie ns:item oder xmlns bleiben als normale Namen erhalten; Namespaces werden nicht aufgelöst.
Was bewirkt die Option Zahlen & Booleans umwandeln?
Ist die Option aktiv, werden die Texte true und false zu echten JSON-Booleans und Zahlenwerte wie 249.90, 14 oder 1e5 zu echten Zahlen. Werte mit führenden Nullen (007) oder nacktem Dezimalpunkt (.5) bleiben Strings, damit keine Daten verfälscht werden. Attributwerte werden genauso behandelt.
Was passiert mit Kommentaren, Leerraum und Processing Instructions?
Kommentare und Processing Instructions wie die XML-Deklaration werden entfernt, reiner Leerraum zwischen Elementen wird ignoriert — das JSON enthält nur Ihre Daten. Die Eingabe muss genau ein Wurzelelement enthalten; dessen Attribute und Kinder werden zu den obersten JSON-Keys, der Wurzelname erscheint in der Statuszeile.