Skip to content
K Knidox Search…
Computer Science · Data

JSON Formatter

Pretty-print, minify, and validate JSON — paste it in and see errors instantly.

Mode
Indent
68 chars
Try an example — tap to load
Valid JSON6898 chars
Formatted output
{ "name": "Knidox", "type": "tool", "free": true, "tags": [ "json", "format" ] }

Format mode re-indents JSON into a readable tree with 2-space, 4-space, or tab indentation. Minify mode strips every space and line break to one compact line for smaller payloads. Both first validate the JSON: if it parses, you get a green “Valid JSON”; if not, the parser’s exact error shows where it broke.

What formatting and validation do

JSON (JavaScript Object Notation) is a text format for structured data, but real-world JSON often arrives on a single crammed line or with inconsistent spacing. Formatting parses the data and re-prints it with consistent indentation so nesting is obvious at a glance. Minifying does the opposite — it removes all optional whitespace to shrink the file for storage or network transfer. Validation is the shared first step: the tool runs the text through a strict parser, so anything it accepts is guaranteed to be well-formed JSON.

Why the same parser does both

Whether you format or minify, the tool calls the same strict JSON parser and rebuilds the output from the parsed structure rather than editing your text directly. That is why a stray comma or a single quote stops the process with an error instead of producing broken output — the parser refuses to guess. Only valid input reaches the formatting or minifying step, so the result is always canonical, machine-readable JSON.

  1. 1
    Paste your JSON. Drop the raw text into the input box — a single line or many lines both work.
  2. 2
    Choose Format or Minify. Format re-indents for reading; Minify collapses everything to one line.
  3. 3
    Pick an indent (Format only). Select 2 spaces, 4 spaces, or a tab to match your project’s style.
  4. 4
    Read the status. A green “Valid JSON” means it parsed; a red error shows the parser’s message and roughly where it failed.
  5. 5
    Fix errors and copy. Correct any reported issue — often a trailing comma or single quotes — then copy the clean output.

Core JSON syntax rules

Break any of these and the parser rejects the whole document.

RuleAllowedNot allowed
String quotesDouble quotes only: "name"Single quotes: ’name’
Object keysEvery key is a double-quoted stringUnquoted keys like name:
Trailing commasNo comma after the last item[1, 2, 3,] or {"a": 1,}
CommentsNone — JSON has no comment syntax// line or /* block */ comments
Valuesstring, number, true, false, null, object, arrayundefined, NaN, Infinity, functions
Numbers42, -3.14, 1.2e10Leading zeros (01) or hex (0xFF)

Reading the error message

When JSON is invalid the tool shows the browser’s native parser message, such as “Unexpected token } in JSON” or “Unexpected end of JSON input.” These messages point to the first place the parser could not continue, which is usually at or just before the real mistake. The most common culprits are a trailing comma before a closing bracket, single quotes instead of double quotes, an unquoted key, or a missing bracket. Fix the earliest error and re-check, since one broken bracket can cascade into several confusing messages.

Why is my JSON invalid when it looks fine?
The two most common causes are a trailing comma before a closing “]” or “}”, and single quotes instead of double quotes. JSON forbids both. Also check for unquoted keys and missing brackets, which the parser reports as an unexpected token.
What does Minify actually do?
Minify parses your JSON and re-prints it with no spaces, indentation, or line breaks — everything on one line. The data is identical; only the optional whitespace is removed, which makes the payload smaller to store or send.
Can I use single quotes in JSON?
No. The JSON standard requires double quotes for both strings and object keys. Single quotes are valid in JavaScript but not in JSON, so ’name’ must become "name" before it will parse.
Why are comments not allowed?
JSON has no comment syntax at all — neither // line comments nor /* block */ comments. Any comment causes a parse error. Formats like JSONC or JSON5 add comments, but standard JSON does not, so strip them first.
Does formatting change my data?
No. Formatting and minifying only change whitespace and indentation. Keys, values, order within arrays, and data types stay exactly the same — the output parses back to an identical structure.
Which indent should I choose — 2 spaces, 4 spaces, or tab?
It is purely stylistic and does not affect validity. Two spaces is the most common default for JSON and web configs; four spaces or a tab can improve readability for deeply nested data. Match whatever your project or team uses.