Skip to content
86% off$349 $48.86code BF2026

Guides

Repair Broken JSON on Mac: Comments, Trailing Commas, Quotes

Fix JSON with comments, trailing commas or single quotes on a Mac. Repair it offline in Bytepliers with a change report, or fix by hand and check in Terminal.

GuideUpdated 7 min read

On this page

You have a config file, an API response or a snippet from a chat, and a strict parser rejects it. It looks fine to you, but it has a comment, a trailing comma or single quotes somewhere. This guide covers what usually breaks, how to fix it by hand, and how to repair it offline on a Mac with a record of every change.

Why strict parsers reject JSON that looks fine

JSON as defined by RFC 8259 is stricter than JavaScript or Python. These are the usual causes, roughly in order of how often they show up:

  • Comments (// note or /* note */). Common in tsconfig.json and editor settings files, which are often parsed by tools that allow them.
  • A trailing comma before } or ].
  • Single-quoted strings or unquoted keys, as in a JavaScript object literal.
  • Python or JavaScript values: True, False, None, undefined.
  • NaN or Infinity, which JSON has no way to express.
  • Smart quotes (curly quotes) added by a chat app, document editor or web page.
  • A whole document pasted as an escaped string, such as "{\"a\":1}".

Numeric keys and raw control characters inside strings also break strict parsers. Bytepliers' Lenient mode repairs all of the above.

SymptomLikely causeFix
Error at a } or ]Trailing commaDelete the comma
Error at the first /CommentDelete the comment
Error at the first ' or a bare wordSingle quotes or unquoted keyUse double quotes
Error at True or NonePython outputUse true, null
Error at N or INaN or InfinityReplace with null or a string
Whole text starts and ends with "Escaped documentUnescape it first

Fix it by hand (no app)

For one small file, any text editor will do:

  1. Delete // and /* … */ comments.
  2. Delete any comma directly before a closing } or ].
  3. Change single quotes around keys and strings to double quotes. Leave apostrophes inside text alone.
  4. Put double quotes around bare keys.
  5. Change True, False and None to true, false and null.

Then check the result in Terminal. This command only reads the file and prints it, so there is nothing to undo:

bash
python3 -m json.tool broken.json

It prints formatted JSON if the file parses, or an error with a line and column if not. On a Mac without Apple's Command Line Tools, macOS may offer to install them the first time you run python3.

Repair broken JSON with Bytepliers (offline)

  1. Open Bytepliers and choose JSON Formatter in the sidebar, or press ⌘1 (Command-1). The first launch shows the All Tools grid until you have used a tool.
  2. Put the broken JSON in the JSON input pane: paste with ⌘V, click Paste from Clipboard, drop a file on the editor, or press ⌘O to open one.
  3. Check that the parsing menu in the toolbar says Lenient ("Lenient — repairs broken JSON"). It is the default.
  4. Read the Formatted output. A Repaired N issues note appears. Open it to see a popover listing each fix with its Ln:Col, ending with "N fixes · output is strict JSON".
  5. Copy the result with ⇧⌘C (Shift-Command-C) or save it with Save… (⌘S).

Strict JSON has no comments, so the repaired output does not contain them. Keep your original if the comments matter.

Check the repair list before you use the result

Repair changes your text, so read the list. Two details matter:

  • Number literals and key order are kept verbatim. Keys are only reordered if you turn on Sort Keys (off by default).
  • NaN and Infinity become strings by default. If your consumer expects null, set NaN and Infinity to As null in the parsing menu.

The Format and Minify tabs switch the layout. Indent offers 2 spaces (default), 4 spaces or Tab.

Use Strict mode to validate

Choose Strict ("Strict — RFC 8259 only") to find out whether a file is valid for a strict parser. If the input fails in Strict mode but Lenient could parse it, a Switch to Lenient button appears. That tells you the file only works with a forgiving parser, and you should repair it before sending it to anything strict.

Files with several JSON documents

If Bytepliers detects several documents separated by line breaks (NDJSON), it shows two tabs: One per line (default) and Wrap as array. The status line then reads "N documents · N values". Choose Wrap as array to get one JSON array.

Check the result with jq or JSONPath

Under the output is a filter bar. Pick jq (default) or JSONPath and type a filter such as .items[] | .name or $.items[*].name. It is a quick way to confirm the repaired data has the shape you expect. The Text | Tree tabs show the same data as a collapsible tree. The tree is a viewer, so you can't edit values in it.

Open files from Finder

Bytepliers appears under Finder's Open With for .json, .geojson, .ndjson and .jsonl files, and you can drop files on its Dock icon. It never becomes your default app for them.

Comparing your options

OptionRepairs comments, trailing commas, single quotesReport of what changedCost (as of November 2026)
Manual edit in a text editorYou do it yourselfNoFree
python3 -m json.toolNo, it rejects themError with line and columnFree
Bytepliers JSON FormatterYes, in Lenient modeYes, with Ln:Col per fixMacSuite, $349 one-time; 7-day free trial
OK JSONHas a repair modeNot verifiedMac App Store $24.99 (14-day trial), or $29.49 direct (5 Macs)

We make Bytepliers, so weigh our view accordingly. OK JSON is a dedicated JSON app with a repair mode, a tree navigator and editor, and jq, JSONPath and JSON Patch support. Pick it if JSON is all you need and you want a single-purpose purchase. Bytepliers puts 41 developer tools in one window and is sold as part of the MacSuite bundle, with one license for every MacSuite app. For more options, see our best JSON viewers for Mac.

Checklist before you try again

  • The parsing menu says Lenient, not Strict.
  • The input is under 64 MB (files over 50 MB ask for confirmation).
  • The status shows "Repaired N issues" or "Valid JSON", not an error marker.
  • You pasted into the JSON Formatter window, not the Quick Panel.
  • Your trial is active or a license key is entered.

If repair doesn't work

The input still shows an error. The editor marks the failing line and column. Lenient mode covers the cases listed above, but not every kind of damage, such as truncated text or missing brackets. Fix the marked spot by hand. While the input has an error, the tree view keeps showing the last valid result, dimmed.

Quick Panel or Detect & Replace won't format it. Both use the strict JSON parser, so repaired JSON doesn't go through them. Paste into the JSON Formatter window instead. See Quick Panel, Instant Replace and the menu bar.

"Nesting too deep". JSON nested more than 100 levels is refused.

The file is huge. The JSON Formatter accepts up to 64 MB. Opening a file over 50 MB asks for confirmation because large files can make the editor slow, and files over 256 MB are refused.

Bytepliers asks for a license. Each MacSuite app has its own 7-day trial. After it ends, the app opens the license window until you enter a key. The JSON Formatter doc covers the formatter's options, and Bytepliers troubleshooting covers the rest.

If none of that helps, contact support through the support page and include the details below.

text
Subject: Bytepliers JSON Formatter won't repair my JSON

Bytepliers version: (Bytepliers menu > About Bytepliers)
macOS version:
Parsing mode: Lenient
Error text and the Ln:Col shown:
What I pasted (a short sample with secrets removed):
Steps already tried: switched Strict/Lenient, restarted the app

Common questions

Does my JSON leave my Mac?

Not through the tools. Update checks and license checks don't include your JSON. The one other network feature in the JSON Formatter is Open URL or cURL…, which runs only when you click Send and goes straight to the server you entered.

Is the JSON I paste saved?

Each tool keeps recent inputs in a local history file and restores each tool's last input at launch. You can turn both off in Settings ▸ History. Text that looks like a secret, such as a JWT, private key or API token, is not recorded unless you turn on Also record inputs that look like secrets.

Is there a Terminal version?

Repair is a feature of the JSON Formatter window. The bytepliers command-line tool has a json-format transform for plain formatting. For Terminal options, see How to format JSON on Mac.

Can Lenient mode change my data?

It changes syntax, not values or key order, and lists each fix so you can check it. The exception is NaN and Infinity, which become strings unless you choose As null.

Every app.
One purchase.