JSON-Formatierer und Validator

Antwort: Der JSON Formatter & Validator erstellt Ihre Ausgabe sofort aus den von Ihnen bereitgestellten Eingaben – alles läuft in Ihrem Browser, kostenlos, ohne dass eine Anmeldung erforderlich ist.

Formatieren, validieren, verkleinern und verschönern Sie JSON sofort

Warte auf Eingabe...
Hier erscheint die formatierte Ausgabe...
Ad

Was ist JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format that's easy for humans to read and write, and easy for machines to parse and generate. It's the standard format for APIs, configuration files, and data storage. JSON supports exactly six data types — strings, numbers, booleans, null, objects, and arrays — and its grammar is strict enough that a single misplaced comma or quote makes the whole document unparsable. That strictness is why a formatter with instant validation matters: it tells you not only that something is wrong but where the parser gave up.

Alles, was dieser Formatierer tut, geschieht in Ihrem Browser. Ihr JSON-Code wird niemals hochgeladen und ist daher sicher für API-Antworten, die private Daten, Anmeldeinformationen in Konfigurationsdateien oder noch in der Entwicklung befindliche Nutzlasten enthalten.

Formatieren, Minimieren und Validieren

Formatting (also called beautifying or pretty-printing) re-inserts indentation and line breaks so the structure of nested objects and arrays is visually obvious. Minifying does the opposite — it strips every byte that isn't required by the grammar, producing the smallest valid document for transmission. Validating parses the document and reports success or the exact position of the first syntax error without changing anything. All three operate on the same text, so you can round-trip freely: minify an API response to see its size, format it to read its structure, validate after every edit.

Häufige JSON-Fehler

Striktes JSON vs. alltägliches JavaScript

Viele Dokumente, die wie JSON aussehen, sind in Wirklichkeit JavaScript-Objektliterale, und der Unterschied besteht genau darin, woher die meisten Validierungsfehler kommen. In der folgenden Tabelle sind die Konstrukte aufgeführt, die JavaScript toleriert, JSON jedoch strikt verbietet.

KonstruktJavaScriptStrenges JSONFix
Zeichenfolgen in einfachen AnführungszeichenErlaubtUngültigVerwenden Sie doppelte Anführungszeichen
Schlüssel ohne AnführungszeichenErlaubtUngültigZitieren Sie jeden Schlüssel
Nachgestellte KommasErlaubtUngültigLöschen Sie das letzte Komma
KommentareErlaubtUngültigEntfernen oder in ein Wrapper-Format verschieben
Undefinierte WerteErlaubtKein JSON-TypVerwenden Sie null oder lassen Sie den Schlüssel weg
NaN / UnendlichErlaubtUngültige ZahlenVerwenden Sie null oder eine Zeichenfolge

Wenn es auf die Größe ankommt: Kompromisse bei der Minimierung

Minified JSON is what APIs actually ship — indentation costs bytes on every request. But the savings only come from whitespace: minification does not rename keys, shorten strings, or restructure data. A large minified document and its formatted twin contain identical information, so gzip compression largely erases the difference on the wire; formatting matters most for local files, logs, and developer tooling rather than production transfer. A useful workflow is to keep source files formatted for readability and generate the minified version as a build step, exactly as you would with JavaScript or CSS.

JSON im Ökosystem

JSON's dominance means most adjacent formats are JSON with extensions. JSON5 relaxes the grammar for humans, permitting comments, trailing commas, and unquoted keys. JSON Lines (JSONL) stores one JSON value per line, popular for logs and streaming datasets. JSON with Padding (JSONP) is a legacy cross-domain technique that predates CORS and is now obsolete for new work. GeoJSON adds coordinate structures for geographic data, and JSON Schema describes the shape a document must have, enabling validation beyond mere syntax. A strict formatter like this one is the common denominator across all of them: syntax-level correctness is the first gate any of these formats must pass.

Lesen von tief verschachteltem JSON

The practical pain of reading JSON scales with nesting depth. At two or three levels, indentation alone is enough. Beyond that, a few habits help: scan for the key you need at each level rather than reading linearly; note array boundaries early, since a misplaced bracket is the most common reason an expected key "disappears" (it lives in a sibling element of an array you skipped); and when hunting one value inside a huge document, format it, copy the path down as you descend, and paste the fragment into a scratch file. Errors reported at the end of a document usually mean an unterminated construct somewhere above — a missing closing brace or quote — which is exactly the case where a formatter's error position beats eyeballing.

Häufig gestellte Fragen

Wird mein JSON an einen Server gesendet?

Nein. Formatierung, Minimierung und Validierung werden alle lokal in Ihrem Browser mit JavaScript ausgeführt. Nichts, was Sie einfügen, wird übertragen oder gespeichert, daher ist das Tool sicher für vertrauliche Daten.

Was ist der Unterschied zwischen JSON-Formatierung und -Validierung?

Durch die Formatierung wird das Dokument mit konsistenter Einrückung neu geschrieben, während Inhalt und Struktur erhalten bleiben. Bei der Validierung wird das Dokument lediglich analysiert und gemeldet, ob es syntaktisch korrekt ist. Dabei ändert sich nichts. Dieses Tool führt eine kontinuierliche Validierung durch, während Sie tippen, und formatiert es bei Bedarf.

Warum verbietet JSON Kommentare?

Die JSON-Spezifikation definiert eine minimale Nur-Daten-Grammatik; Kommentare wurden bewusst weggelassen, um die Parser einfach und das Format eindeutig zu halten. Gängige Problemumgehungen sind ein dedizierter „_comment“-Schlüssel, JSON5 für Menschen oder YAML, wo Kommentare erstklassig sind.

Kann dieses Tool defektes JSON automatisch reparieren?

Es validiert und meldet die Fehlerposition genau, errät jedoch nicht die Absicht. Reparieren bedeutet zu entscheiden, was der Autor gemeint hat – das Entfernen eines abschließenden Kommas ist sicher, aber die Wahl zwischen zwei möglichen Anführungszeichen für eine nicht geschlossene Zeichenfolge ist kein Urteil, das ein Tool stillschweigend treffen sollte.

Ändert die Formatierung meine Daten?

Nein. Durch die Formatierung werden nur Leerzeichen zwischen Token angepasst. Schlüsselreihenfolge, Werte und Struktur bleiben exakt erhalten; Die Ausgabe wird erneut auf die identischen Daten wie die Eingabe analysiert.