๐Ÿ› ๏ธ Developer ยท Updated October 8, 2026 ยท 8 min read

Format JSON Online and Fix Syntax Errors Automatically

Messy JSON Clean JSON ๐Ÿงฉ

When JSON will not parse, paste it into the GrabCast formatter: it validates as you type, prints the line and column of the first problem with a caret under the exact character, and a Repair button rewrites common breakage into valid JSON while listing every change it made. Once the data passes, you can beautify it with 2 spaces, 4 spaces or tabs, compact it, sort keys, browse it as a tree or pull values out with JSONPath. This page is the troubleshooting reference: the strict rules a validator enforces, what Repair can and cannot rescue, how to read the error position, and how to confirm a large repaired file is complete.

๐Ÿงฉ Try JSON Formatter now โ€” freeOpen โ†’
JSON Formatter after Repair and Beautify turned the invalid Lisbon widget config into valid JSON
From invalid input to clean, valid JSON in two clicks.
๐Ÿ’ก Why so much JSON arrives broken

Strict JSON forbids things people type every day: comments, single quotes, unquoted keys, a comma after the last item, and Python values like True or None. Config files for editors and build tools often allow comments, browser consoles print JavaScript objects rather than JSON, and chat apps silently swap straight quotes for curly ones. The parser in your code rejects all of it with a terse message like unexpected token at position 812. Finding position 812 by eye in a minified blob is miserable, which is why a tool that points at the character and can fix the routine cases saves real time.

What the Repair button fixes in broken JSON

Repair runs a lenient parser that understands JSON5, JavaScript object literals and Python dictionaries, then writes the result back as standard JSON. The status line names each category it touched, so nothing changes silently.

Treat the last item with care. Closing a truncated array makes it valid, but whatever was cut off is still missing, so compare record counts with the source.

Reading the error caret and status line

If the text is not valid and Repair cannot help, the error box quotes the browser parser message and shows the offending line with a caret under the column. A missing comma between two objects on line 48, for example, is flagged at the first character of the second object, which is where the parser gave up rather than where the comma belongs. Look one token to the left.

When the data is valid, the status line reports the number of items for a top-level array, the total count of keys, the nesting depth and the size in bytes. Those numbers are a quick sanity check: an export that should contain 1,200 orders but reports 1,199 items deserves a closer look before you import it anywhere.

The rules a JSON validator checks, and what it skips

Validation is a yes-or-no test against the strict grammar in RFC 8259. Almost every failure comes from breaking one of a short list of rules, so it pays to know them by heart.

What a validator does not check is meaning. A payload can be perfectly well formed and still miss a required field, carry a price as a string or put a date in the wrong format. Catching that needs a JSON Schema check in your code or pipeline. Treat a passing result as the first gate, not the last one.

Tree view and JSONPath for large repaired payloads

After a repair, the Tree tab is the fastest way to confirm the structure is what you expected. It renders objects as collapsible nodes that load their children only when opened, which keeps multi-megabyte files responsive. Nodes with more than 1,000 children show the first 1,000 plus a note pointing you to a query. Click any key and its path, such as $.orders[3].shipping.zip, is copied and dropped into the query box.

Files up to 50 MB open locally, and nothing is uploaded, so tokens and internal configs stay on your device. The cost is memory: a 50 MB file needs several times that in RAM while it is parsed, so keep files smaller on a phone. Duplicate keys parse without warning and only the last value survives, so if two copies of a key might exist, search the raw text for it before trusting the output.

If your source is YAML or XML, use the YAML to JSON converter or the XML Formatter & Validator to get it into shape first.

Step-by-step

1234
1Open the JSON Formatter and paste your data, open a file, or drop a .json, .json5, .js or .txt file up to 50 MB onto the input box.
Broken weather settings with a comment, single quotes and trailing commas; error points to line 2 column 3
Paste the data; the status line points at the first syntax error.
2Read the status line; if it shows an error, check the caret line and the token just before it, then press Repair and review the list of fixes it reports.
After Repair the status reads Valid JSON and lists the fixes: comments, single quotes, unquoted keys, trailing commas
Press Repair and read the list of fixes it reports.
3Choose 2 spaces, 4 spaces or tab indentation, tick Sort keys if you plan to compare versions, and press Beautify or Minify.
Repaired settings beautified with 2-space indent: city Lisbon, units metric, refreshMinutes 15, alerts wind and rain
Beautify the repaired JSON, then copy it or download it as .json.
4Check the item count and the last records in the Tree or JSONPath tab, then copy the result or download it as a .json file.

Common mistakes to avoid

โš ๏ธTrusting a repaired file that was truncated without checking whether records at the end are missing.
โš ๏ธPasting a Python print() dump and editing quotes by hand instead of letting Repair convert True, False and None in one pass.
โš ๏ธSearching for an error at the reported position when the real problem, usually a missing comma or bracket, sits just before it.
โš ๏ธMinifying a config file you or your team edit by hand, which makes future diffs unreadable.

Pro tips

โœ“Tick Sort keys before comparing two exports in a diff tool so ordering changes do not hide the real differences.
โœ“Use Repair on package.json-style files copied from blog posts, which often carry curly quotes that break npm.
โœ“Click keys in the Tree view to build JSONPath expressions instead of typing long paths from memory.
โœ“Keep NaN and Infinity out of APIs entirely; the repair turns them into null, which may change the meaning of a metric.
โœ“For NDJSON logs, repair once to get an array, then query fields like $..level to count errors quickly.

Frequently asked questions

Is my JSON uploaded to a server?

No. Parsing, repair, formatting and queries all run in your browser, so you can safely paste tokens or customer data.

What are the most common reasons JSON is invalid?

Single quotes, a trailing comma after the last item, a missing or mismatched bracket, an unescaped quote inside a string, and comments, which standard JSON does not allow.

Can it read JSON5 or JSON with comments?

Yes. Press Repair and it converts JSON5, JavaScript object literals and Python dictionaries into standard JSON, listing each fix.

Why does the error position look wrong?

The parser reports where it stopped, which is usually just after the real mistake. Check the previous line for a missing comma or quote.

If my JSON validates, will my app accept it?

It will parse, but the app may still reject it if a required field is missing or a value has the wrong type. That needs a schema check, not just a syntax check.

๐Ÿ“Œ Bottom line

Paste, validate, repair and format in one tab: the GrabCast JSON Formatter points at the exact character that broke, fixes comments, quotes, commas and Python literals while telling you what changed, and lets you inspect big files with a lazy tree and JSONPath. Remember that passing validation proves syntax, not content, and check repaired truncated data for missing records.

Open JSON Formatter โ†’

Related guides

Browse more: all text and developer guides ยท JSON Formatter