DevFormatter

JSON Lint

 

JSON Lint — Syntax Checker

How JSON Lint works

Last updated: November 2026

JSON (JavaScript Object Notation) is a lightweight text format for structured data, defined by RFC 8259. JSON linting means checking a JSON string for syntax errors — the same concept as linting in programming languages like JavaScript or Python.

Paste JSON into the left panel and click Validate (or just paste — it validates automatically). The right panel shows the result: type, key/item count, and byte size on success, or the exact error with a fix suggestion on failure.

The most common JSON errors a linter catches:

  • Trailing commas — ["a", "b",] is invalid JSON
  • Single-quoted strings — JSON requires double quotes on keys and values
  • Comments — JSON has no comment syntax (// ... and /* ... */ are both invalid)
  • Unquoted keys — keys must always be double-quoted strings
  • Mismatched brackets — every { needs a matching }, every [ needs a ]

All processing runs entirely in your browser via the native JSON.parse() function — your data never leaves your machine.

Common JSON Errors and Fixes

Trailing comma

{ "name": "Alice", "age": 30, }  ← invalid (trailing comma)
{ "name": "Alice", "age": 30 }   ← valid

Single-quoted strings

{ 'name': 'Alice' }   ← invalid (single quotes)
{ "name": "Alice" }   ← valid

Comments (not allowed in JSON)

{
  // user info
  "name": "Alice"
}

Comments are not valid JSON. Use JSONC or JSON5 formats if you need comments in config files.

Tips & Tricks

SyntaxError position is byte-based, not character-based

The position in a JSON.parse SyntaxError refers to the byte offset in the UTF-8 encoded string. For ASCII JSON this matches the character position exactly, but multi-byte Unicode characters (emoji, CJK) will cause the reported column to be higher than the visual character count.

tsconfig.json uses JSONC, not JSON

TypeScript config files (tsconfig.json), .eslintrc, and .babelrc use JSONC (JSON with Comments) which allows // ... and trailing commas. Standard JSON.parse will reject these — use a JSONC-aware parser like jsonc-parser from npm.

Numbers have precision limits in JSON

JSON.parse converts numbers to IEEE 754 doubles. Integers larger than Number.MAX_SAFE_INTEGER (9,007,199,254,740,991) lose precision silently. Use string values for large IDs or monetary amounts, or parse with a bigint-aware library like json-bigint.

Duplicate keys are valid JSON but dangerous

The JSON spec (RFC 8259) does not forbid duplicate keys — they are "SHOULD NOT" not "MUST NOT". However, different parsers handle duplicates inconsistently: some keep the first value, others keep the last. Use the JSON Formatter to detect duplicate keys before shipping.

NaN and Infinity are not valid JSON values

NaN, Infinity, and -Infinity are JavaScript values that JSON.stringify outputs as null. If your API returns these bare (without quotes), the JSON is technically invalid — receivers may tolerate it, but it is non-standard.

The error position may point past the actual mistake

JSON parsers report where parsing failed, not where the mistake is. A missing closing brace near the top can cause the error position to point to the very end of the file. When the position seems wrong, check for unclosed structures earlier in the JSON.

Lint JSON Programmatically

Node.js

try {
  JSON.parse(input);
  console.log('valid');
} catch (e) {
  console.error(e.message); // includes position
}

Python

import json
try:
    json.loads(text)
    print("valid")
except json.JSONDecodeError as e:
    print(f"Error at line {e.lineno}, col {e.colno}: {e.msg}")

CLI (jsonlint)

# npm install -g jsonlint
jsonlint data.json

# Or with Node.js one-liner:
node -e "try { JSON.parse(require('fs').readFileSync('data.json','utf8')); console.log('valid'); } catch(e) { console.error(e.message); }"

Frequently Asked Questions

What does JSON lint mean?
JSON lint (or JSON linting) means checking a JSON string for syntax errors — the same concept as linting in programming languages. A JSON linter parses the input against RFC 8259 and reports the exact line and column of any error, such as a trailing comma, single-quoted string, or unquoted key.
What errors does a JSON linter catch?
Trailing commas after the last array item or object property, single-quoted strings (JSON requires double quotes), unquoted keys, JavaScript-style comments (JSON has no comment syntax), missing colons between keys and values, and mismatched or missing braces and brackets.
Is my JSON data sent to a server?
No. All linting runs entirely in your browser using the native JSON.parse() function. Your data never leaves your machine and no account is required.
What is the difference between JSON lint and JSON validation?
JSON lint and JSON validation mean the same thing for basic syntax checking — both verify that a JSON string is well-formed according to RFC 8259. The term "validation" is sometimes extended to include JSON Schema validation, which checks that values match a schema. JSON linting always means syntax checking only. See the JSON Validator for schema-focused checking, or JSON Formatter to fix and reformat in one step.
Can I lint JSON with a trailing comma?
Trailing commas are invalid in JSON and a linter will flag them. They are common in JavaScript object literals and TypeScript config files (tsconfig.json, .eslintrc) but the JSON spec (RFC 8259) does not allow them. If your file uses trailing commas, it is JSON5 or JSONC, not standard JSON.
How do I lint JSON in Node.js?
Use JSON.parse() inside a try/catch block. The thrown SyntaxError message includes the position of the error. For CI pipelines, the command-line tool jsonlint (npm install -g jsonlint) reports errors with line numbers.
How do I lint JSON in Python?
Use json.loads() inside a try/except block and catch json.JSONDecodeError. The exception exposes .lineno and .colno for the exact error position.
What is the difference between jsonlint and JSON.parse?
JSON.parse() is the built-in browser and Node.js function — it parses JSON and throws a SyntaxError. The npm package jsonlint wraps a more detailed parser and outputs structured errors suitable for CI pipelines and build scripts.
Why does JSON not allow comments?
JSON was designed as a minimal data interchange format. Comments were deliberately excluded because JSON is meant to be parsed by machines, not read like source code, and different parsers handle them inconsistently. If you need comments in config files, use JSONC (supported by VS Code and TypeScript configs) or JSON5 — both are supersets of JSON that allow comments.
What does "unexpected token" mean in a JSON error?
An "unexpected token" error means the parser encountered a character it did not expect at that position. Common causes: a missing comma between two items, a stray character outside a string, a comment (// or /* */), or an unquoted property name. The error position points to the unexpected character — the actual mistake is usually on the line before it.
Can JSON have duplicate keys?
The JSON spec (RFC 8259) says duplicate keys in an object "should" be unique but does not make them an error. Most parsers silently keep the last value and discard earlier ones — JSON.parse() in browsers does the same. This tool flags duplicate keys as a warning so you can find them before they cause unexpected behaviour in production.
What is the difference between JSON and JSONC?
JSONC (JSON with Comments) is a superset of JSON that allows single-line (//) and multi-line (/* */) comments. It is used by VS Code's settings.json and TypeScript's tsconfig.json. JSONC is not valid standard JSON — JSON.parse() will reject it. Strip comments before passing JSONC to a standard JSON parser.

Related Tools

Other free developer tools available on DevFormatter.