What Format, Validate, and Minify Actually Do
All three operations begin with the same question: does this text match the JSON grammar defined by RFC 8259? The page first calls JavaScript's JSON.parse(). Success means the input is syntactically valid JSON and has been converted to an in-memory value; failure means no output is produced. “Valid JSON” is a syntax result, not proof that the document matches your API schema, contains the required fields, or has safe business values.
Format & Validate then calls JSON.stringify(parsed, null, indent), using your selected two-space, four-space, or tab indentation. The result is easier to scan, review in a pull request, compare in a diff, and inspect by eye. Minify calls JSON.stringify(parsed) with no indentation, removing whitespace that JSON does not require. It is still built from the parsed value, so Minify validates too; it is not a looser parser that can repair malformed input.
Round-tripping through parse and stringify preserves the represented JSON value only within JavaScript's data model. It normalizes text: duplicate object names collapse to the last value accepted by JavaScript, number spelling and property enumeration can change, and integers beyond JavaScript's safe-number range can lose precision. If exact bytes matter for a checksum, signature, cache key, audit record, or byte-for-byte deployment diff, keep the original and compare those bytes rather than assuming the formatted output is canonical.
Debug First, Minify at the Delivery Boundary
Use formatted JSON while writing configuration, reading a compact API response, reviewing a schema, or diagnosing a parse failure. Use minified JSON only when a downstream consumer needs a smaller serialized artifact and humans no longer need to read it—for example, a generated production asset, a cache payload, or a network-response fixture. Formatting a large API request before development may make the payload easier to inspect, while minifying the release artifact reduces raw characters.
Whitespace is not compression. HTTP gzip or Brotli usually removes much of the repetitive indentation created by pretty-printing, so a minified body is not always dramatically smaller after transport compression. Also, do not minify a source configuration merely to save a few kilobytes if that makes future incident review or rollback harder. A sound production workflow keeps readable source, validates it in CI, and minifies only in a deterministic build step.
Errors That Frequently Break an Otherwise Valid Document
JSON is deliberately strict: object names and strings use double quotes, comments are not part of the format, commas separate members or elements, and there is no trailing comma. These are the failures this page most often surfaces:
- Trailing comma:
{"items": [1, 2,]}and{"name": "Ada",}are invalid. Remove the comma after the final value. - JavaScript-style quotes or keys:
{'name': 'Ada'}and{name: "Ada"}are object-literal syntax, not JSON. Use{"name": "Ada"}. - Comments:
// noteand/* note */are rejected. JSON has no comment syntax; move explanations outside the document. - Missing separator or unbalanced delimiters: adjacent object members need a comma, and structural
{,[,], and}symbols must match. The same characters inside a quoted string are ordinary content and do not affect structural balance. - Unescaped string characters: a literal newline or tab inside a quoted string breaks the document. Encode them as
\nand\t; escape an embedded double quote as\". - Values JavaScript accepts but JSON does not:
undefined,NaN,Infinity, function calls, and bare identifiers are not JSON values. Usenull, valid JSON numbers, strings, booleans, arrays, and objects.
The reported line and column come from the browser engine's parse error. Treat it as the first token that could not be accepted; a missing comma or quote one line earlier can make the visible token look innocent. Check the preceding delimiter and string boundary as well as the highlighted position.
Syntax Validation Is Not Schema Validation
A syntactically valid document can still violate the contract of the system consuming it. This page does not have a JSON Schema, so it does not reject a missing id, an unexpected property, a string where a number is required, or a business rule such as “quantity must be positive.” Those checks require the relevant schema, generated types, or application rules. Treat “Valid JSON” as “the parser accepted the grammar,” then validate semantics separately when correctness matters.
The formatter does not submit your JSON. Its parsing, formatting, minifying, and Copy action run in the page and the script contains no upload endpoint or browser-storage call. That is not a blanket guarantee for every secret: pasted text remains in the live page DOM and may be exposed by a compromised site script, browser extension, endpoint monitoring, screenshots, or clipboard history. The wider site also loads analytics and advertising resources under its consent controls. Use synthetic data when possible; for real credentials or regulated data, use a locally installed, trusted workflow.
Frequently Asked Questions
What are the most common JSON syntax errors?
Common failures include trailing commas, single-quoted strings, unquoted object keys, comments, missing commas, unbalanced structural brackets, unescaped control characters in strings, and values such as undefined, NaN, or Infinity. Both Format & Validate and Minify reject these because the input must pass JSON.parse first.
How do I read the error location this tool gives me?
The line and column, when exposed by the browser engine, identify the first token it could not accept. Check that position and the preceding comma, quote, and bracket because an earlier mistake can make a later token look innocent.
What's the difference between JSON and a JavaScript object literal?
JSON has a strict interchange grammar: object names and strings use double quotes, comments and trailing commas are forbidden, and values are limited to JSON types. JavaScript object literals allow forms such as single-quoted names, comments, and trailing commas, so JavaScript source is not automatically valid JSON.
Is my pasted data sent anywhere?
The formatter script has no upload request and does not save the input to browser storage. However, pasted text remains in a live web-page DOM and can still be exposed by compromised code, extensions, endpoint controls, screenshots, or the clipboard. Prefer synthetic data; use trusted local tooling for real credentials or regulated data.
What's the difference between formatting and minifying?
Both operations first parse and validate the input. Formatting adds readable indentation for development and review; minifying removes optional whitespace for a deliberate compact delivery artifact. Whitespace is not compression, and gzip or Brotli may remove much of the difference.
Can I validate very large JSON files?
There is no documented fixed size cap, but parsing, copying, and rendering a very large document can make the browser interface slow or unresponsive. For multi-megabyte or larger files, a command-line validator such as jq or python -m json.tool is usually more reliable.