U
UseCalcForge Free Online Calculators
Developer Tools

JSON Validator & Formatter.

Check whether a JSON string is valid, then prettify it with indentation or minify it to a single line.

Reviewed by the UseCalcForge editorial desk | Last updated
Before you paste

Redact secrets first.

Your JSON is sent to our server to be parsed, then discarded — it is not logged or stored. Even so, replace live API keys, tokens and passwords with placeholder values before pasting a config file or API response into any online tool.

RFC 8259 4-space indent UTF-8

Processed on our server. What you enter is sent over an encrypted connection, calculated, and returned. It is never written to a database or logged, and nothing is retained once the result is sent. Avoid entering passwords, API keys or other secrets. How we handle data

What this validator checks

JSON (JavaScript Object Notation) is the text format almost every web API uses to send data. It is strict: a single misplaced comma makes the whole document unreadable to a parser, and the error you get back is often a vague “Unexpected token”.

This tool parses your input against the JSON standard (RFC 8259, also published as ECMA-404). If it parses, you get it back either prettified — one value per line with 4-space indentation — or minified to a single line with no extra whitespace. If it does not parse, you get the parser’s error message. Anything that passes here will also be accepted by JSON.parse() in JavaScript, json.loads() in Python, and json_decode() in PHP.

The errors you will actually hit

JSON looks like a JavaScript object, but it is much stricter. Nearly every “Syntax error” comes from one of these:

  • Trailing comma. {"a": 1, "b": 2,} is invalid. Delete the comma after the last item in every object and array.
  • Single quotes. {'name': 'Ann'} is invalid. Keys and strings must use double quotes.
  • Unquoted keys. {name: "Ann"} is valid JavaScript but invalid JSON. Write {"name": "Ann"}.
  • Comments. // and /* */ are not allowed. Config files such as VS Code’s settings use a looser format called JSONC that does allow them; strip the comments before validating here.
  • JavaScript-only values. undefined, NaN, Infinity and functions do not exist in JSON. Use null, or a string, instead.
  • Raw line breaks or tabs inside a string. These must be escaped as \n and \t. This often happens when text is pasted from a document.

The error message does not give a line number, so for a long document the quickest way to find the problem is to halve it: delete the second half of an array or object, validate, and repeat on whichever half still fails.

Prettify or minify?

Prettify

Puts each value on its own line with 4-space indentation. Use it when reading an API response, reviewing a config change, or pasting JSON into documentation.

Minify

Removes every space and line break that is not inside a string. Use it when the JSON is going into an environment variable, a single-line log entry, or a request body where size matters.

How much minifying saves depends on how the JSON was formatted to begin with. A deeply nested file indented with spaces can shrink by a quarter or more; one that was already compact barely changes. If the JSON is served over HTTP with gzip or Brotli compression, most of that whitespace saving is already captured by the compression.

Questions

Will formatting change my data?

No values change, but a few representation details may. Escaped characters such as é are written out as the character itself (é), and escaped forward slashes (\/) become plain slashes. Both forms mean exactly the same thing to any JSON parser. If the same key appears twice in one object, only the last value is kept, which is also what most parsers do.

Why did a very long number change?

Integers larger than about 9.2 quintillion, and decimals with more than about 15 significant digits, cannot be stored exactly as numbers and are rounded. JavaScript has the same limit (above 9,007,199,254,740,991). If you need IDs that long to survive, send them as strings.

Is there a size limit?

Nesting is limited to 512 levels. For files of several megabytes, a local editor or a command-line tool such as jq will be faster than any web page.

Working with SQL too?

The SQL formatter tidies up long queries into readable, indented form.

Open SQL formatter
Knowledge Base

JSON Validation and Formatting Methodology.

Validating JSON before you send it turns a vague 400 Bad Request from an API into a specific, fixable error. Paste a payload above to check it, then prettify it to read it or minify it to ship it.

The Calculation Branch

Valid JSON: keys are double-quoted strings; values are a string, number, object, array, true, false or null; no trailing commas; no comments

Industrial Standards.

Your input is parsed with PHP's json_decode on our server, which follows RFC 8259. If parsing succeeds it is re-encoded with json_encode, either with pretty-print indentation or with no whitespace. Empty objects stay as {} and numbers such as 1.0 keep their decimal point. Nothing you paste is logged or stored.

In-Depth Analysis & Reference Data

A quick checklist when a payload is rejected: look for a comma after the last item of an object or array; replace single quotes with double quotes; put quotes around every key; remove comments; replace undefined, NaN or Infinity with null; and escape any raw line breaks inside strings as \n. Those six fixes cover most of the invalid JSON produced by hand-editing or by copying a JavaScript object from browser dev tools.

Frequently asked questions.

What is the difference between JSON and a JavaScript object?

JSON requires double-quoted keys, forbids comments and trailing commas, and allows only six value types. Many valid JavaScript objects are therefore invalid JSON, but valid JSON is always a valid JavaScript expression.

When should I minify JSON?

When it needs to fit on one line, such as in an environment variable or a log entry, or when you are storing many records and size adds up. For anything a person will read, keep it prettified.

Estimates for planning. Always confirm against an authoritative source.