Codepackr / validators / JSON Validator

JSON Validator

Strictly validate JSON syntax and pinpoint exact error line and column.

Client-Side Execution & Privacy Guarantee

This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.

JSON is a strict text format. A single missing comma or an unquoted key renders an entire document invalid for parsers. CodePackr's JSON Validator checks syntax locally and reports the precise location of the first error so you can fix it without guessing.

Unlike lenient JavaScript object literal parsers, this tool follows the JSON specification. It rejects trailing commas, single-quoted strings, and comments. The result is either a clean parse or a clear diagnostic that names the line and column.

What constitutes valid JSON

Valid JSON consists of objects, arrays, strings, numbers, booleans, and null. Object keys must be double-quoted strings. Numbers cannot have leading zeros (except for zero itself) or trailing decimal points.

Whitespace is allowed between tokens but not inside strings. The document must contain exactly one top-level value; trailing content after a complete value is an error.

Common syntax errors and their reports

A missing comma between object properties or array elements produces an error at the position where the parser expected a comma or the next token. Trailing commas after the last element are rejected with a message pointing at the comma.

Unquoted keys and single quotes around strings are reported as unexpected tokens. Control characters inside strings must be escaped; an unescaped newline is flagged at the start of that line.

Using the location information

The reported line and column are 1-based and count from the beginning of the input. Column counts characters, not visual width, so tabs and wide unicode characters still count as one column each in the diagnostic.

When the error is near the end of a long line, copy the line into an editor that shows column numbers. Fix the token at that column, then re-validate; subsequent errors will surface only after the first one is corrected.

When to use this tool

  • A configuration file or API response fails to parse and you need the exact character that is wrong.
  • You are generating JSON from a template or script and want to confirm it is free of trailing commas.
  • You receive JSON from an external system and must verify it before further processing.
  • You are writing tests that assert a payload is valid JSON and want a reproducible error message.
  • You need to confirm that a minified document is still syntactically correct after editing.

How to use the JSON Validator

  1. Paste the JSON document into the input area.
  2. Click validate or let the tool check automatically as you type.
  3. If the document is valid, the tool confirms success and optionally pretty-prints the structure.
  4. If invalid, read the error message together with the reported line and column.
  5. Locate the indicated position in your original text and correct the token.
  6. Re-validate to confirm the fix and to catch any subsequent errors.
  7. Copy the validated JSON for use in your application or further tools.

Worked examples

Missing comma between properties

Input
{
  "name": "Ada",
  "year": 1815
  "role": "mathematician"
}
Output
Error at line 4, column 3: Expected ',' or '}' after property value

The parser finished the second property and then saw another key without a separating comma.

Trailing comma in array

Input
[1, 2, 3,]
Output
Error at line 1, column 9: Unexpected token ','

JSON does not allow a trailing comma after the last element of an array or object.

Common mistakes and tips

  • Remove comments and trailing commas before pasting; both are illegal in strict JSON.
  • If the error column seems off, check for invisible characters or a BOM at the start of the file.
  • Pretty-print a valid document first if the original is minified; the line numbers will then match the formatted version.
  • Numbers must not contain leading zeros. Change 01 to 1 or quote it if it is meant to be a string.
  • An empty document or pure whitespace is invalid; JSON requires a value.

Frequently asked questions

Does the validator accept JSON5 or comments?

No. It implements strict JSON only. Comments, unquoted keys, and trailing commas are rejected.

Why does the column number differ from my editor?

The tool counts characters. Tabs are one character; some editors expand them visually. Convert tabs to spaces for easier alignment.

Can it validate against a schema?

No. This tool checks syntax only. Use a separate schema validator once the document parses.

What is the maximum size it can handle?

It runs in the browser, so very large documents may be slow or hit memory limits of the tab. For multi-megabyte files, validate in smaller chunks or use a local command-line tool.

Is my JSON uploaded?

No. Validation occurs entirely in your browser.