Free Online JSON Formatter & Validator
Format, validate, and minify JSON instantly. Syntax highlighting and clear error messages.
Formatted JSON appears here
What Is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging structured data. Originally derived from JavaScript, it is now language-independent and supported natively by virtually every programming language. JSON is the dominant format for REST APIs, configuration files, database exports, and inter-service communication.
A valid JSON document is either an object ({"key": "value"}),
an array ([1, 2, 3]), or a primitive value (string, number,
boolean, or null). Keys must always be double-quoted strings. Values can be any of the
six JSON types.
Format vs Minify — When to Use Each
Format / Beautify for readability: when debugging an API response, reading a config file, reviewing JSON data in a code review, or documenting an API. Formatted JSON is easier to diff in version control.
Minify for production: before writing JSON into an HTTP response body,
embedding in a <script> tag, or storing in a size-sensitive location.
Whitespace can account for 20–40% of a typical JSON payload. Minification removes all
of it without changing the data.
Common JSON Errors and How to Fix Them
- Unexpected token — usually a trailing comma after the last item in an object or array (
{"a":1,}). Remove the final comma. - Unexpected end of JSON input — the JSON is cut off or incomplete. Check that all brackets and braces are properly closed.
- Expected double-quoted property name — keys are written without quotes or with single quotes. All keys must be double-quoted strings.
- Bad control character — the JSON contains a literal tab or newline inside a string. These must be escaped as
\tor\n.
How to Use JSON Formatter
-
1
Paste your JSON
Paste raw or minified JSON into the input editor. You can also load a sample to see the formatter in action.
-
2
Choose indent size
Select 2-space or 4-space indentation depending on your project style guide. The formatted output updates immediately.
-
3
Format, validate, or minify
Click Format to pretty-print, Validate to check for errors, or Minify to compress the JSON into a single line for production use.
-
4
Copy the result
Click Copy to copy the formatted or minified JSON to your clipboard, ready to paste into your code editor or API client.
Frequently Asked Questions
undefined, NaN, and Infinity are not valid values. If your JSON breaks any rule, JSON.parse() throws an error. This tool catches those errors and shows the exact error message from the browser's parser so you can fix the problem quickly.
JSON.stringify(JSON.parse(input)), which also validates the input as a side effect.
JSON.parse() and JSON.stringify() APIs. Your JSON data is never sent to a server. This is especially important when working with API responses that contain sensitive data like tokens, user records, or configuration files.
// ... or /* ... */), trailing commas, and unquoted keys are valid JavaScript but not valid JSON. If you have a file in one of these formats (sometimes called JSONC or JSON5), you will need a dedicated JSONC/JSON5 parser. The most common fix is to remove comments and trailing commas before pasting here.