ToolMint
Developer Tools5 min readMay 17, 2026

How to Validate JSON Online – Common Errors and How to Fix Them

JSON is strict. A single misplaced comma or a pair of single quotes instead of double quotes will cause JSON.parse to throw an error and your entire payload to fail. Unlike JavaScript, JSON has no tolerance for common formatting habits. This guide covers the most frequent JSON syntax errors, how to read the error messages, and how to fix each one quickly.

The 5 Most Common JSON Syntax Errors

1. Trailing comma: a comma after the last item in an object or array. This is valid in JavaScript and TypeScript but illegal in JSON. Wrong: {"a": 1, "b": 2,} Right: {"a": 1, "b": 2} 2. Missing comma: forgetting the comma between two properties or array elements. Wrong: {"a": 1 "b": 2} Right: {"a": 1, "b": 2} 3. Single-quoted strings: JSON requires double quotes for all strings — both keys and values. Wrong: {'name': 'Alice'} Right: {"name": "Alice"} 4. Unquoted property names: property names must be strings in double quotes. Wrong: {name: "Alice"} Right: {"name": "Alice"} 5. Mismatched brackets: an unclosed { or [ anywhere in the document causes a parse error at end of file. Most formatters report this as 'unexpected end of JSON input' or 'Unexpected token' at the last character.

How to Read JSON Error Messages

Browser console: 'SyntaxError: Unexpected token , in JSON at position 47' — this means position 47 (zero-indexed character offset from the start of the string) has an unexpected comma. Count characters from the start or paste into a formatter that converts position to line+column. Node.js: 'SyntaxError: Unexpected token } in JSON at position 120' — the } at position 120 was not expected. Usually means there is a trailing comma before it or a missing opening brace. Python json.decode: 'json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 3 column 5' — directly names the line and column, much easier to locate. The key insight: the error position is where the parser noticed the problem, not always where you made the mistake. A missing closing bracket at line 5 may only surface as an error at line 50 when the parser hits end-of-input. Work backwards from the error location when the obvious fix is not at that position.

Step-by-Step: Fixing JSON with a Formatter

Step 1: Paste your JSON into the ToolMint JSON Formatter input panel. Step 2: The validator runs automatically. If there is an error, the error badge shows the line number and column. Step 3: Navigate to that location in your source and look for: • A trailing comma on the previous line • Single quotes instead of double quotes • A missing comma between properties • An unquoted property name Step 4: Fix the issue in your source, re-paste the corrected JSON, and verify the validator shows 'Valid JSON'. Step 5: Use the Format (beautify) button to see the full structure with proper indentation — mismatched nesting becomes visually obvious in a formatted view.

How to Avoid JSON Errors in Code

Never hand-write JSON for production use. Instead: • In JavaScript/Node: use JSON.stringify(object) to serialize data — it always produces valid JSON • In Python: use json.dumps(dict) — produces valid JSON • In other languages: use the built-in JSON serializer for that language When you must write JSON manually (config files, test fixtures, seed data), use a JSON-aware editor (VS Code highlights syntax errors inline) or run the file through a validator before committing. For config files where trailing commas and comments are convenient, use JSONC (JSON with Comments) format supported by VS Code, or use YAML instead — YAML is a superset of JSON that allows comments and is more forgiving of minor formatting differences.

Try the tools mentioned in this guide

Frequently Asked Questions

Why does JSON not allow trailing commas?
JSON was designed as a strict, language-agnostic data interchange format, not as a JavaScript subset. The specification (RFC 8259) explicitly prohibits trailing commas to ensure unambiguous parsing across all implementations. JavaScript's own object literal syntax does allow trailing commas, which is a frequent source of confusion when copy-pasting JS objects into JSON contexts.
What is the difference between JSON and JavaScript objects?
JSON is a text format for data. JavaScript objects are runtime values. Key differences: JSON requires double-quoted keys; JS objects accept unquoted or single-quoted keys. JSON does not allow functions, undefined, or Symbol values; JS objects do. JSON does not allow comments; JS objects used as config (JSONC, JSON5) can. JSON.parse() converts a JSON string to a JS object; JSON.stringify() does the reverse.
How do I validate JSON in Python?
Use try/except with json.loads(): import json; try: json.loads(your_string); print('valid'); except json.JSONDecodeError as e: print(f'invalid: {e}'). The JSONDecodeError includes the line number and column in the exception message.

Related Guides