- NEW
JSON Fixer & Formatter
Automatically repairs and formats broken JSON, and generates TypeScript types
Screenshots
Great for
- People tired of hunting for the cause of JSON.parse errors
- People who want to turn JS objects or Python dicts into JSON
- People who want TypeScript types from an API response
- People who often break JSON config files when editing them by hand
- People who don't want to paste work data into outside services
What is JSON Fixer & Formatter?
A tool that doesn't just format the JSON you paste but automatically repairs broken JSON that won't parse. You can paste "almost JSON that errors in JSON.parse" as is, such as data copied from JavaScript code, logs or Python output.
How it differs from other JSON formatters
- Automatically repairs broken JSON: Fixes trailing commas, single quotes, unquoted keys, comments, missing closing brackets, missing commas, True / None (Python), NaN / undefined and more
- Lists what it fixed: Instead of silently rewriting, it tells you what it changed, such as "Removed extra trailing commas (2 places)"
- Shows the location when it can't fix something: Points to the problem, such as "line 3, character 12"
- Generates TypeScript type definitions: Merges objects in an array into one type, and marks keys that are sometimes missing with "?"
- Supports JSON Lines and escaped JSON strings: Multi-line JSON becomes an array, and strings like "{"a":1}" are expanded
- Input is processed only in your browser: Safe to use even with data you don't want to leave your machine, such as API responses
Key features
- Repairs trailing, repeated and missing commas
- Converts single quotes, full-width quotes and unquoted keys and values to double quotes
- Removes //, /* */ and # comments
- Repairs unclosed brackets and mismatched bracket types
- Converts Python's True / False / None and NaN / undefined to JSON values
- Extracts JSON from JavaScript code like const data = {...};
- Combines JSON Lines (one JSON per line) into an array and expands escaped JSON strings
- Lists what was fixed and how many places; shows line and character position when it can't fix
- Indentation (2, 4 or tab), minify to one line, sort keys, and \u-escape Japanese
- Generates TypeScript interface / type automatically (optional keys get ?)
How to use
- Paste JSON into the input on the left (broken is OK)
- The formatted JSON appears on the right. What was fixed is listed below the input
- Open the "TypeScript types" tab to see type definitions
- Use "Copy" or "Save to file"
Why I made this
Data copied from logs or source code often turned out to be "almost JSON but unreadable", and I was fixing trailing commas and quotes by hand one by one. I made this not only to fix it, but also to show what was fixed.
— The developer

