JSON repairer
Automatically repair and fix malformed JSON data. Corrects common JSON syntax errors like missing quotes, trailing commas, unescaped characters, concatenated strings, comments, and more. Instantly validates and formats broken JSON into valid, properly structured output.
Input
Output
Readme
What is JSON and why does it break?
JSON (JavaScript Object Notation) is a lightweight data format used for storing and exchanging information between systems. It follows strict syntax rules: strings must use double quotes, objects need proper braces, arrays require brackets, and trailing commas are forbidden. Even a single misplaced character can make the entire document invalid.
JSON commonly breaks when copied from logs, chat messages, or code editors. Hand-editing often introduces errors like missing quotes, unescaped characters, or mismatched brackets. APIs sometimes return malformed responses, and configuration files get corrupted during manual edits.
Tool description
This JSON Repairer automatically fixes broken or malformed JSON documents. It analyzes the input, identifies syntax errors, and reconstructs valid JSON while preserving the original data structure and values. The tool handles common issues that would otherwise require tedious manual correction.
Examples
Missing quotes around keys:
{name: "John", age: 30}Repaired:
{ "name": "John", "age": 30 }Trailing commas:
{ "items": ["apple", "banana", "orange"] }Repaired:
{ "items": ["apple", "banana", "orange"] }Single quotes instead of double quotes:
{'status': 'active', 'count': 5}Repaired:
{ "status": "active", "count": 5 }Unquoted string values:
{"message": Hello World}Repaired:
{ "message": "Hello World" }Missing closing brackets:
{"data": [1, 2, 3}Repaired:
{ "data": [1, 2, 3] }Features
- Automatically adds missing quotes around keys and string values
- Removes trailing commas from arrays and objects
- Converts single quotes to double quotes
- Repairs mismatched or missing brackets and braces
- Optional formatting with pretty-print or minified output
How it works
The repair algorithm parses the input character by character, building a valid JSON structure. When it encounters invalid syntax, it applies correction rules based on common JSON mistakes. Missing quotes are inferred from context, unmatched brackets are closed at appropriate positions, and invalid characters are handled or escaped. The result is syntactically correct JSON that can be parsed by any JSON parser.
Use cases
- Debugging API responses: Fix malformed JSON returned from APIs or web services before processing
- Cleaning log data: Repair JSON fragments extracted from application logs or console output
- Fixing configuration files: Correct hand-edited JSON configs that have accumulated syntax errors
Limitations
- Cannot repair completely unstructured text that has no resemblance to JSON
- May interpret ambiguous input differently than intended (always verify the output)
- Semantic errors (wrong data types, incorrect values) are not detected or fixed