JSON Validator & Repair Tools
Find exactly why JSON is invalid, repair broken JSON from ChatGPT, LLMs and APIs in one click, then compare, query with JSONPath or explore it as a tree. Everything runs in your browser.
How to validate and repair JSON
- Paste JSON into any tab, or open a file from your computer.
- Pick a tool: Format, Validate, Minify, Compare, Tree, Escape, Sort Keys, Flatten, Repair or JSONPath.
- Results update as you type. Errors point to the exact line and column.
- Copy, download or share a link to the result.
Why use these JSON tools
- JSON formatter, validator and minifier in one page
- Compare two JSON documents with a line-by-line diff
- Explore large JSON with a collapsible tree view
- Repair broken JSON from LLMs: code fences, single quotes, trailing commas, truncated output
- Test JSONPath expressions such as
$..book[?(@.price<10)] - Escape/unescape JSON strings, sort keys and flatten nested objects
Related tools
Fix broken JSON from ChatGPT, LLMs and APIs
The Repair tab turns almost-JSON into valid JSON in one click, and shows what it changed so you can check it. It handles the output that breaks JSON.parse and json.loads most often:
- Markdown code fences and surrounding text from ChatGPT, Claude and Gemini answers (“Here is the JSON: ```json …”).
- Truncated output when a model hit its token limit: missing closing brackets and quotes are added.
- Python dictionaries: single quotes,
True/False/None. - JavaScript object literals: unquoted keys, trailing commas, comments.
- Escaped JSON such as
{\"a\":1}copied from logs or string literals. - Invisible characters (zero-width spaces, BOM) that make valid-looking JSON fail.
How to validate JSON and find the exact error
Open Validate and paste your JSON. An invalid document shows the parser’s message with the exact line and column, and a “Try Repair” button that fixes it in one click. Valid JSON shows its size, node count and nesting depth.
Compare two JSON files
Compare shows a line-by-line diff of two formatted JSON documents with added and removed lines counted, useful for API responses before and after a change, or config files across environments.
Prevent broken JSON from LLMs
Ask the model for JSON only, use your provider’s structured output or JSON mode, and validate the schema before using it. The Structured Output Strict Linter checks schemas for OpenAI strict mode.
Frequently Asked Questions
Is the JSON formatter free?
Yes, completely free with no account, login, or signup required. All features are available immediately.
Is my JSON data safe?
All processing happens entirely in your browser. Your JSON is never sent to any server.
What JSON tools are included?
Format (pretty print), Validate, Minify, Tree viewer, Escape/Unescape, Sort keys, Flatten, and Compare two JSON objects.
Does it handle large JSON files?
Yes. The formatter handles large JSON files efficiently in the browser without sending data to a server.
Can I share JSON via a URL?
Yes. Click the Share button to copy a link that restores your JSON and active tab when opened.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. It is human-readable and widely used for APIs, configuration files, and data storage.
How do I format JSON with indentation?
Paste your JSON into the Format tab and choose 2 spaces, 4 spaces, or Tab indent. Click Format to pretty-print it instantly.
How do I validate JSON syntax online?
Switch to the Validate tab, paste your JSON, and the tool highlights exactly which line contains a syntax error.
What is the difference between JSON and a JavaScript object?
JSON is a text string — keys must be double-quoted and trailing commas are not allowed. A JavaScript object is runtime data that allows unquoted keys and functions.
How do I minify JSON for production?
Use the Minify tab. It strips all whitespace and newlines, reducing payload size for HTTP responses and storage.
Can I sort JSON keys alphabetically?
Yes. The Sort tab recursively sorts all object keys alphabetically, which helps with diffing and version control.
What does 'unexpected token' mean in JSON?
It means the parser found a character it did not expect — common causes are a trailing comma, an unquoted key, or a single-quoted string.
How do I compare two JSON objects?
Use the Compare tab. Paste two JSON values and the tool highlights keys that differ, are missing, or have different types.
How do I fix broken or invalid JSON?
Open the Repair tab and paste it. Brace fixes missing or trailing commas, single quotes, unquoted keys, comments, Python True/False/None, unescaped newlines and missing closing brackets, then shows you exactly which lines changed.
Why does ChatGPT or Claude return invalid JSON?
Language models generate text token by token, so replies often wrap JSON in markdown code fences or explanations, use single quotes, add trailing commas, or get cut off at the output limit. The Repair tab strips the surrounding text and fixes these issues in your browser.
How do I test a JSONPath expression?
Open the JSONPath tab, paste your JSON and type a path such as $.store.book[*].author or $..book[?(@.price<10)]. Matches update live, and you can switch between values, paths and JSON Pointers.
How do I flatten nested JSON?
Use the Flatten tab. It converts deeply nested objects into a single-level object using dot notation keys, e.g. user.address.city.