JSON formatter & validator

Paste your JSON to format, validate, and minify it instantly. Nothing leaves your browser.

Indent:

Reading JSON syntax errors

When validation fails, the message names a position in the string. These are the causes behind almost every JSON error, in rough order of frequency.
ErrorCauseFix
Unexpected token } / ]A trailing comma after the last itemJSON forbids trailing commas, unlike JavaScript. Remove it.
Unexpected token 'Single-quoted strings or keysJSON requires double quotes on both keys and string values.
Unexpected token in position 0The response was not JSON at allUsually an HTML error page returned by a server. Check the status code.
Unexpected end of inputA brace or bracket is never closedFormat the document and read the indentation to find the unclosed level.
Unexpected token NA bare NaN, Infinity or undefinedNone are valid JSON. Use null or a string.
Bad control characterA literal newline or tab inside a stringEscape it as \n or \t.
Unexpected non-whitespace after JSONTwo documents concatenated, or NDJSONSplit into separate documents, or wrap the lines in an array.

What counts as valid JSON

JSON is defined by RFC 8259, and it is much stricter than the JavaScript object literals it resembles. Valid JSON permits exactly six value types: object, array, string, number, true/false, and null.

Everything else you might expect is absent. There are no comments, no trailing commas, no single quotes, no unquoted keys, no hex or octal numbers, no leading plus sign, no leading zeros, and no undefined. Dates have no native type either — they travel as ISO 8601 strings by convention, not by specification. This strictness is deliberate: it is what makes JSON parse identically across every language.

Format or minify — when to use which

ModeUse it when
Format (2 spaces)Reading an API response, committing config to git, or debugging. Two-space indentation is the prevailing default in JavaScript and web tooling.
Format (4 spaces)Matching a codebase that already uses four — common in Python and .NET projects.
MinifySending a payload over the network or storing it. Whitespace can be a substantial share of a deeply nested document, and no parser cares.

Numbers are the quiet source of bugs

JSON does not distinguish integers from floats, and it sets no precision limit — but JavaScript parses every number as a 64-bit float. Any integer beyond Number.MAX_SAFE_INTEGER (9,007,199,254,740,991) silently loses precision on parse.

This bites in practice with large database identifiers, Twitter or Discord snowflake IDs, and financial values in the smallest currency unit. The standard fix is to transmit such values as strings. If an ID comes back from an API quoted, that is why — do not unquote it.

Privacy

Validation, formatting and minification all run in your browser through the native JSON parser. Nothing is uploaded, so it is safe to paste production API responses, configuration containing credentials, or customer records.

Frequently asked questions

Can JSON contain comments?

No. RFC 8259 has no comment syntax, and a // or /* */ will fail validation. Formats such as JSONC and JSON5 add comments, but they are separate formats — strip comments before parsing as JSON.

Why is a trailing comma an error?

JavaScript object literals tolerate a trailing comma; JSON does not. It is the single most common JSON syntax error.

Does formatting change my data?

No. Only whitespace changes. Key order is preserved and every value stays exactly as it was.

How should I store a date in JSON?

There is no date type. The convention is an ISO 8601 string such as 2026-08-19T12:00:00Z, which sorts correctly as text and parses everywhere. Unix timestamps as numbers are the other common choice.

Why did my large ID number change?

JavaScript parses JSON numbers as 64-bit floats, so integers above about 9 quadrillion lose precision. APIs avoid this by sending large IDs as strings.

What is the difference between JSON and NDJSON?

NDJSON puts one complete JSON document on each line, with no wrapping array. It streams well for logs and exports, but pasting it here will fail validation — wrap the lines in an array first.

Is my JSON uploaded anywhere?

No. Everything runs locally in your browser using the built-in parser.

Related free tools

JSON to CSVBase64 encoderTimestamp converterCase converter