JSON Formatter — Free Online Pretty-Print & Minify
Format and validate JSON instantly. Pretty-print with 2/4/tab indent or minify to a single line, with color-coded syntax highlighting. Everything runs in your browser — your data stays local.
FreeNo sign-upRuns in your browserDeveloperApplication
The 6 JSON syntax errors that trip people up most
JSON looks like a JavaScript object literal but follows a stricter grammar (RFC 8259) — most "invalid JSON" reports are one of a handful of repeat offenders, usually from copy-pasting JS code or a trailing comma left over from editing.
| Error | Invalid example | Why it fails | Fix |
|---|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | JSON has no trailing commas, unlike modern JS | Remove the comma before } or ] |
| Single quotes | {'a': 1} | JSON strings and keys must use double quotes only | Use "a" not 'a' |
| Unquoted keys | {a: 1} | JS object shorthand is not valid JSON | Quote every key: {"a": 1} |
| Comments | {"a": 1 /* note */} | JSON has no comment syntax at all | Delete comments — JSON has no equivalent |
| NaN / undefined / Infinity | {"a": NaN} | These are JS values with no JSON equivalent | Use null, or a sentinel string like "NaN" |
| Leading zeros | {"a": 007} | Numbers cannot have leading zeros | Write 7, or quote it as a string "007" |
- JSON5 and JSONC (JSON with Comments, used by VS Code's settings.json and tsconfig.json) relax several of these rules — trailing commas and comments are allowed — but this tool validates against strict JSON (RFC 8259), so JSONC files need comments stripped before pasting them in.
How to format and validate JSON online
- Paste your JSON. Paste raw JSON into the editor, or drag a .json file into the drop zone / click Upload File.
- Pick indent style. Choose 2 spaces, 4 spaces, or tab indentation for the Format / Prettify output.
- Format or minify. Click Format / Prettify for a readable, syntax-highlighted, indented view, or Minify for a single-line output ready for transmission.
- Copy or clear. Invalid JSON shows the exact parser error message in red. Copy the formatted output with one click, or Clear to start over.
Frequently Asked Questions
- Is my JSON uploaded or logged?
- No. Formatting and minifying run entirely in your browser. Nothing is sent to a server.
- What is the maximum file size?
- Up to ~10 MB performs smoothly. Larger files may slow the editor. For >50 MB consider a CLI tool like jq.
- Does the output have syntax highlighting?
- Yes. Formatted and minified output color-codes strings, numbers, booleans, null, and object keys so structure is easy to scan.
- What happens if my JSON is invalid?
- The tool shows the parser's exact error message so you can find and fix the problem quickly.
- Can I upload a file instead of pasting?
- Yes. Click Upload File or drag a .json/.txt file directly into the input area — its contents load into the editor.
- Will it preserve number precision?
- JavaScript number precision (53-bit) is preserved. For larger integers (BigInt), use a CLI tool.
Use Cases
- Debug API responses by pretty-printing raw JSON
- Minify JSON config before embedding in HTML or environment variables
- Spot-check a config file's structure with color-coded syntax highlighting
- Validate JSON syntax before pasting into a config file
- Upload a .json file straight from disk instead of copy-pasting
Related tools
More free, in-browser tools from the Developer Tools set — every one runs locally, with no sign-up and no upload.
Code MinifierMinify JS / CSS / HTML. Copy-ready, no dependencies.Base64 EncoderEncode or decode text and files with one click.QR GeneratorGenerate crisp SVG/PNG QR codes. Wi-Fi & vCard presets.QR ReaderDecode QR codes from an image, pasted screenshot, or live camera — free, no upload.HTML PreviewLive sandboxed HTML editor + preview with device widths — code never leaves your browser.Color PickerDrop an image, steal its palette. HEX · OKLCH · RGB.