Tools · Text · JSON formatieren und validieren · Anleitungen · JSON Format vs Minify: Which One Do You Actually Need
JSON Format vs Minify: Which One Do You Actually Need
Format and Minify sit right next to each other as a two-option switch, and it's easy to treat them as one setting you pick once and forget. They're actually answers to two different questions. Format is for a person about to read the JSON. Minify is for a machine about to store or transmit it. Picking the wrong one for the situation doesn't break anything, but it does waste bytes in one direction or readability in the other.
When Format is the right call
Format is for the moments a human is actually going to look at the text: debugging an API response in a browser tab, reading through a config file to check a value, pasting a payload into a bug report so a teammate can see the structure at a glance. The indentation and line breaks cost nothing functionally - JSON.parse doesn't care about whitespace - they exist purely to make nested structure visible to a person's eyes, which is exactly what a person needs when they're trying to find one wrong value inside forty.
The indent width matters more than it seems. 2 spaces is compact and common in JavaScript-adjacent tooling; 4 spaces reads more like Python-style config and is easier to scan at a glance in a wide array of objects; a tab character respects whatever indent width the reader's own editor is set to display. Match whichever convention the destination file already uses, so a formatted paste doesn't introduce an inconsistency the next person has to clean up.
When Minify is the right call
Minify strips every byte of formatting whitespace, which matters anywhere size is the actual cost: a JSON value embedded in a URL query parameter, a payload sent over a slow connection, a config value stored in an environment variable or a database column with a length limit. None of those destinations benefit from indentation a person will never read directly - every space and newline in a formatted blob is a byte spent on nothing but human readability, and once the data leaves your editor, that readability isn't doing any work.
It's worth being clear about what minifying doesn't do: it doesn't remove data, rename keys, or change the structure in any way. The minified output carries exactly the same keys and values as the formatted version, just without the whitespace between them. Anything that parses the formatted output will parse the minified one identically.
A case that trips people up: pasting from a config file
Someone editing a hand-written .json config often reaches for Minify out of habit, assuming smaller means safer to paste back in. For a file that stays on disk and gets edited again later by a person, that's backwards - a minified config is harder to review in a diff, harder to spot a wrong value in, and saves bytes nobody was paying for on a local file. Format is the better default for anything that lives in a repository and gets read by humans over time; Minify is for the moment that same data crosses a wire or gets embedded somewhere space is actually limited.
A third option this tool deliberately doesn't offer
Some developers reach for a "compact but still somewhat readable" middle ground - a 1-space or 3-space indent, or a format that keeps short arrays on one line. This tool sticks to exactly three choices: 2 spaces, 4 spaces, or a tab, because those three cover the near-totality of real style-guide conventions in actual use, and a fourth or fifth option mostly adds a decision to make rather than a real need to fill. If your project's style guide specifically requires an unusual indent width, format at 2 or 4 and adjust in your editor's own reformat step - a one-time conversion, not something this tool needs to special-case.
If what you're pasting isn't strict JSON at all
A file with comments, trailing commas, or unquoted keys - common in hand-maintained config files that call themselves JSON but were written with a lenient parser in mind - won't format or minify here; it reports as invalid, honestly, rather than silently accepting a relaxed syntax this tool was never built to parse. That's a deliberate scope boundary, not a missing feature: a validator whose job is confirming strict JSON validity would be doing something different, and arguably less useful, if it quietly accepted things that aren't actually JSON. If your source file genuinely needs comments or trailing commas, the honest fix is deciding whether it should really be JSON at all, or a format built for exactly that (JSON5, JSONC, YAML), not asking a strict validator to pretend otherwise.
What doesn't change either way
Duplicate keys stay put in both modes - the formatter keeps every key exactly as written, so Format and Minify both show a repeated key twice, and whatever reads the file afterwards (JSON.parse keeps the last value) decides which one wins. Numbers and strings are copied untouched as well, so a 20-digit ID or a 1.10 comes out exactly as it went in. And whichever mode you land on, the check that got you a valid result in the first place runs entirely in your browser - the formatter never sends the JSON anywhere, whether you're about to read it or ship it.