Zum Inhalt springen
NeedToConvert

JSON formatieren

JSON lesbar formatieren oder minifizieren, die genaue Stelle eines Syntaxfehlers finden und die Daten als aufklappbaren Baum durchsuchen.

  • Kostenlos
  • Privat
  • Ohne Anmeldung
Läuft auf Ihrem Gerät. Ihre Eingaben werden nicht hochgeladen.

A one-line API response, a minified config file or a log entry copied from a terminal is close to unreadable until it is indented. Paste it here and it is reformatted as you type, with a Valid JSON badge when it parses, or a precise explanation of what is wrong and where when it does not.

The formatter uses a strict RFC 8259 parser written for this page instead of the browser's JSON.parse, which is why it can do three things many online formatters cannot: point at the exact line and column of an error in plain words, keep large numbers digit for digit, and warn about repeated keys. Your JSON stays in the browser tab, which matters when it contains tokens, customer records or internal endpoints.

What valid JSON looks like

JSON, specified in RFC 8259 and ECMA-404, is stricter than the JavaScript it came from. Keys and strings need double quotes, not single quotes. A comma after the last item of an array or object is an error. Comments are not allowed, and neither are NaN, Infinity, undefined, hexadecimal numbers or leading zeros such as 007. Tabs and line breaks inside a string must be escaped as \t and \n. Most errors people hit come from pasting JavaScript object literals, JSON5, or JSONC files such as VS Code settings with comments into a strict parser.

When the input breaks one of these rules, the result pane names the problem, for example Remove this comma: JSON does not allow a comma before a closing bracket or brace. It also shows the line and column and marks the offending character in a copy of that line. Messages cover trailing commas, single quotes, unquoted keys, comments, bad escape sequences, invalid numbers, unclosed strings, raw control characters and text after the end of the document.

When developers reach for a formatter

Debugging API responses

curl output and payloads copied from the browser's network tab are usually minified. Formatting reveals the structure, and the Tree view lets you collapse large arrays to find the field you need.

Shrinking payloads

Minify strips every space and line break. For JSON embedded in an environment variable, an HTML data attribute or a request body, it leaves nothing but data.

Comparing two JSON documents

Turn on Sort keys and format both versions the same way. Key order no longer matters, so a text diff of the two outputs shows only real changes in values.

Options and what they change

Mode switches between Format and Minify, and Format offers an indent of 2 spaces, 4 spaces or Tab. Sort keys orders the keys of every object at every level by UTF-16 code unit, the same order jq -S uses, so uppercase letters sort before lowercase. Arrays keep their order, because in JSON the position of an array item is meaningful.

Numbers are copied exactly as written. JSON.parse turns 9007199254740993 into 9007199254740992 because JavaScript numbers are 64-bit floats, which silently corrupts database IDs, snowflake IDs and amounts in some financial APIs. This formatter never converts the number, so 1.0 stays 1.0 and 1e5 stays 1e5. Strings are re-escaped in a standard way: \u00e9 is written as é and \/ as a plain slash, which changes the text but not the data.

The statistics show input and output size in bytes, the number of values and the nesting depth. Tree view opens the first two levels, lists up to 200 children at a time with Show more, and shortens strings longer than 300 characters for display. A byte order mark at the start is removed with a note, and repeated keys in one object trigger a warning, because most programs keep only the last value.

So verwenden Sie dieses Tool

  1. Paste JSON into the JSON box, open a .json file with Open file, or press Sample.
  2. Pick Format or Minify under Mode, and for Format choose 2 spaces, 4 spaces or Tab.
  3. Turn on Sort keys if you want keys in alphabetical order, and switch View to Tree to explore the structure.
  4. If an error box appears, fix the marked character in the input; once the Valid JSON badge shows, press Copy or Download.

Limitations

  • The parser is strict on purpose: JSON5 and JSONC features such as comments and trailing commas are reported as errors, not repaired.
  • Input is limited to 10,000,000 characters and nesting to 1,000 levels.
  • Only the first error is reported. Once it is fixed, the next one, if any, appears.
  • Duplicate keys are kept in the output as written; the tool warns about them but does not decide which value is right.
  • The output pane previews up to 200,000 characters; Copy and Download always contain the full result.

Häufig gestellte Fragen

Why does my JSON fail with an unexpected character?

The usual causes are single quotes around strings, keys without quotes, a trailing comma or a comment, and each has its own message here. Text copied from JavaScript code, a Python dictionary printed to the console or a JSON5 file is not JSON yet and needs those parts converted.

Does formatting change my data?

No. Formatting only adds or removes whitespace between tokens. Keys keep their order unless you turn on Sort keys, and numbers keep their exact digits. The only textual change is that escape sequences such as \u00e9 are written as the character itself, which is the same string.

What is the difference between Format and Minify?

Format adds line breaks and indentation so people can read the document. Minify removes all optional whitespace to produce the smallest valid JSON for machines. Both contain exactly the same data.

Is it safe to paste API keys or personal data?

The text is processed by JavaScript in this page and is not sent to a server, logged or stored. Closing the tab discards it.