🔧 Auto-Fix Invalid JSON

Paste broken JSON and let the tool automatically detect and fix common issues.

📂 Drag & drop a .json file here, or click to browse
Input (Broken JSON)
Font:
0 chars · 0 lines

Example — Broken JSON

{ name: "Alice" 'age': 30, "skills": ["JavaScript", "Python",], "address": {"city": "NYC" }

Issues: unquoted keys, single quotes, trailing comma, missing comma, missing closing brace.

Have questions? Check our FAQ page.

How Auto-Fix Works

Invalid JSON is one of the most common frustrations developers face. A single missing comma, an unquoted key, or a trailing comma can break an entire configuration file or API payload. Rather than manually hunting for errors, this tool automatically detects and repairs common JSON syntax issues.

Issues This Tool Can Repair

How Is This Different from JSON Lint?

Traditional JSON validators like JSONLint only tell you what's wrong — they report errors but don't fix them. This tool goes further by actually repairing the broken JSON automatically. It shows you exactly which fixes were applied, so you can learn from the corrections and understand what went wrong.

Related Tools

Common JSON Syntax Errors Explained

JSON has a strict syntax that does not tolerate the flexibility found in JavaScript objects or other data formats. Understanding why these errors occur and how to recognize them will help you write cleaner JSON and debug problems faster. This guide covers each common error type in detail, explains where they come from, and shows you how to prevent them.

Missing Commas

Missing commas between key-value pairs or array elements is the most frequent JSON error. It typically happens when you add a new property or array item and forget to add the comma after the previous one.

// ❌ Invalid - missing comma between properties { "name": "Alice" "age": 30 } // ✅ Valid - comma added { "name": "Alice", "age": 30 }

This error often appears when manually editing JSON files or when copying code from JavaScript where trailing commas are allowed. The parser error message typically says "Expected comma" or "Unexpected string" at the line where the missing comma should be.

Trailing Commas

A trailing comma is a comma after the last item in an object or array. JavaScript allows this, but strict JSON does not. This is one of the most common errors when copying JavaScript objects to JSON files.

// ❌ Invalid - trailing comma after last item { "colors": ["red", "green", "blue",] } // ✅ Valid - no trailing comma { "colors": ["red", "green", "blue"] }

Many modern code editors and linters can automatically remove trailing commas. This tool detects and removes them automatically during the fix process.

Unquoted Keys

In JavaScript, object keys do not need quotes if they are valid identifiers. JSON requires all keys to be quoted strings with double quotes. This error commonly appears when copying JavaScript object literals directly into JSON files.

// ❌ Invalid - unquoted keys { name: "Alice", age: 30 } // ✅ Valid - keys in double quotes { "name": "Alice", "age": 30 }

This tool automatically wraps bare identifiers in double quotes. However, if the key contains special characters or spaces, manual quoting may be required.

Single Quotes Instead of Double Quotes

JSON strictly requires double quotes for strings. Single quotes, which are valid in JavaScript, Python, and many other languages, cause parse errors in JSON.

// ❌ Invalid - single quotes { 'name': 'Alice', 'city': 'New York' } // ✅ Valid - double quotes { "name": "Alice", "city": "New York" }

This error often appears when copying data from Python dictionaries or JavaScript using single-quote style. The fix tool automatically converts all single quotes to double quotes.

Unmatched Brackets and Braces

Every opening bracket [ needs a closing ], and every opening brace { needs a closing }. Missing brackets typically occur when editing deeply nested structures or when copy-pasting partial JSON.

// ❌ Invalid - missing closing brace { "user": { "name": "Alice", "address": { "city": "NYC" } // ✅ Valid - all brackets matched { "user": { "name": "Alice", "address": { "city": "NYC" } } }

This tool attempts to add missing closing brackets at appropriate nesting levels. However, for severely malformed JSON, manual intervention may be needed to ensure the structure is correct.

Understanding JSON.parse Error Messages

When JSON fails to parse, browsers and runtimes provide error messages that can help locate the problem. Understanding these messages speeds up debugging:

Prevention Strategies

The best way to avoid JSON errors is to prevent them from being introduced in the first place:

When Auto-Fix Cannot Help

This tool fixes syntax errors, but it cannot fix semantic errors or logical problems:

JSON Validation vs JSON Fixing

Validation and fixing are complementary but different operations. Validation tells you whether JSON is correct and reports specific errors. Fixing attempts to repair those errors automatically. A typical workflow is: try to parse, if it fails then auto-fix, then validate the result to confirm it is correct.

For production systems, always validate JSON at boundaries — when receiving API input, reading configuration files, or processing user uploads. Auto-fix tools are excellent for development and debugging but should not replace proper validation in production code.

Manual Debugging Techniques

When auto-fix cannot solve the problem, try these manual debugging approaches:

Understanding these errors and how to fix them makes you a more effective developer. While this tool handles most common issues automatically, knowing what is happening under the hood helps you write better JSON and debug problems faster when they occur.