JSON Formatter
Format, beautify, or minify JSON instantly in your browser. Validates syntax with line-level error reporting, supports key sorting, and lets you copy or download the result.
Format, beautify, or minify JSON data instantly in your browser — no server, no upload, no data leaves your device. Paste raw or minified JSON, load a .json file, choose your indent style and output mode, then click Format JSON. The formatter validates the syntax, pretty-prints or minifies the result, and shows you the data type, key count, line count, and file size. Copy the result to the clipboard or download it as a .json file.
How to use
Paste JSON into the input area, or click Load file to open a .json or .txt file from disk. You can also drag and drop a file directly onto the input. Choose your options, then click Format JSON. If the input contains a syntax error the formatter highlights the exact line and column so you can fix it quickly. The formatted result appears below — use Copy to copy to the clipboard, or Download .json to save the file.
Options
- Indent with — 2 spaces, 4 spaces, or tab character. Applies only in Beautify mode.
- Output mode — Beautify adds indentation and newlines for readability; Minify strips all unnecessary whitespace to produce the smallest possible output.
- Sort keys — Sorts all object keys alphabetically at every nesting level. Useful for diffing JSON files or normalising API responses.
What the formatter does
- Parses the input using the browser's native
JSON.parse()for strict RFC 8259 compliance. - Reports parse errors with a line number and column so you can locate the problem instantly.
- Pretty-prints using
JSON.stringify()with your chosen indent. - Recursively sorts object keys when the Sort keys option is enabled.
- Shows the top-level data type (object, array, string, number, boolean, null) and the number of keys or array items.
Common JSON errors explained
| Error message | Common cause |
|---|---|
| Unexpected token | Trailing comma after the last item, or unquoted key/value |
| Unexpected end of JSON input | Missing closing } or ] |
| Unexpected string | Two values without a separating comma |
Always use double quotes for strings and keys — single quotes are not valid JSON. Remove trailing commas before the last item in objects and arrays.
FAQ
What is the difference between beautify and minify?
Beautify adds newlines and indentation to make JSON human-readable. Minify removes all unnecessary whitespace to reduce file size — useful for API payloads or configuration files sent over a network.
Does it support JSON5 or JSONC (JSON with comments)?
No. The formatter uses the browser's built-in JSON.parse(), which follows the strict JSON specification. Comments, trailing commas, and single-quoted strings are not valid JSON and will produce a syntax error.
What happens to the key order when sorting is off?
Key order follows the order they appear in the original input, as parsed by the JavaScript engine.
Is my data sent to a server?
No. All parsing and formatting is done entirely in your browser using JavaScript. Your data never leaves your device.
Can it handle large JSON files?
Yes — there is no file size limit imposed by the tool. Very large files may take a brief moment to parse and format in the browser.
Why does the formatter report a syntax error even though my JSON looks correct?
Check for these common issues: trailing commas after the last item, single-quoted strings instead of double-quoted, unquoted property names, or undefined values (which are not valid in JSON).