Skip to content
ToolForge
Developer Tools

JSON Formatter and Validator

Free online JSON formatter and validator. Beautify or minify JSON, get precise error messages with the exact line and column, sort keys and validate against a schema.

Free, no sign-upRuns in your browserNothing uploaded

Valid JSON

Parsed successfully.

Output, read only.

input
215 B
output
297 B
change
+82 B
objects
3
arrays
1
keys depth
3
strings
7
numbers
3

Paste JSON in, get readable JSON out. The formatter pretty-prints with two, four or tab indentation, minifies back to a single line, sorts object keys alphabetically and strips whitespace inside strings if you need that. It is the fastest way to read an API response that arrived as one enormous line.

The validator is the part worth having. When JSON is invalid, almost every tool just says SyntaxError. This one tells you the line and column, shows the offending line with a caret under the exact character, and classifies the problem - a trailing comma, an unquoted key, a single quote instead of a double quote, a missing colon, a bare value. Those five account for nearly all real-world JSON errors, and naming the cause saves the guessing.

Everything is parsed in your browser with the native JSON parser, so a large payload cannot be used to attack anything and never leaves your device. You can also paste a URL to fetch and format a remote API response, validate against a JSON Schema, and switch between a syntax-highlighted view and plain text.

JSON Formatter & Validator features

Precise error reporting
Line and column plus a caret under the exact character, with the cause named - trailing comma, unquoted key, single quotes, missing colon or bare value.
Format and minify
Pretty-print with two spaces, four spaces or tabs, or collapse to a single line.
Sort keys and strip string whitespace
Alphabetise object keys recursively, or collapse whitespace inside string values for tokens and payloads.
Escaped and unicode output
Optionally escape non-ASCII characters as \uXXXX for environments that mangle UTF-8.
Live statistics
Characters, lines, depth, object and array counts and byte size for both input and output, so you can see what minification saved.
JSON Schema validation
Paste a schema and get a list of per-path validation errors against draft 2020-12.
Large payload safe
Parsing happens in a Web Worker for inputs over a threshold, so a multi-megabyte response does not freeze the tab.
Nothing uploaded
The parser runs entirely in the page. There is no endpoint that receives your JSON.

How to use the JSON Formatter & Validator

  1. Paste your JSON

    Type or paste into the editor. Examples and any JSON Schema you have used are remembered in this browser only, so you can come back to the same work.

  2. Choose an action

    Format to prettify, Minify to compress, Sort keys to alphabetise object keys, or Compact strings to remove whitespace inside string values.

  3. Read the result

    The output is syntax highlighted and updates as you type. Character count, line count, object and array counts and the estimated byte size are shown under both panes.

  4. Fix any error

    If the input is invalid you get the line and column, a caret pointing at the character, and a plain-language description of what went wrong.

  5. Copy or download

    Copy the formatted output, or download it as a .json file. Minified output is typically 40 to 70% smaller than the formatted version.

Frequently asked questions

Why does my JSON say 'Unexpected token' even though it looks right?

JSON is far stricter than JavaScript object literals. The usual culprits are single quotes instead of double quotes, unquoted keys, a trailing comma before a closing brace or bracket, a JavaScript comment, or an undefined or NaN value. The validator names which of these it found and points at the character.

Does JSON allow comments?

No, not in the standard. JSON Schema and JSON Lines are separate specifications. Most parsers including JavaScript's JSON.parse reject // and /* */ comments. This tool gives a specific 'comments are not allowed in JSON' message so you do not have to guess.

How much smaller does minifying make a file?

On typical minified API responses there is little left to strip. On JSON that has been pretty-printed or hand-edited, expect 40 to 70%. Gzip and Brotli compress whitespace very efficiently, so on a real HTTP connection the extra saving is much smaller than the raw byte count suggests.

Can I format a JSON file directly?

Yes. Drop a .json file onto the editor or use the file button and it is loaded and formatted. Files of several megabytes are handled in a worker.

Is my JSON sent anywhere?

No. Parsing, formatting and validation all run inside your browser tab. Nothing is transmitted, so there is no size limit and nothing to leak.

What is the difference between JSON.parse and JSON5?

JSON.parse implements the strict standard. JSON5 allows comments, trailing commas, single quotes, unquoted keys, plus signs and hex numbers. JSON5 is friendlier to write by hand but not valid JSON - if something has to be parsed by a strict consumer, convert it with this tool first.

Every tool, in one place

ToolForge has json formatter & validator plus a growing set of image, colour and developer tools. All of them run locally in your browser, free and without an account.

Browse all tools