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

Guides

How to Format JSON on Mac (Terminal and Apps)

Format and pretty-print JSON on a Mac with jq or python3 in Terminal, repair JSON that won't parse, and format the clipboard with a hotkey, all offline.

GuideUpdated 9 min read

On this page

The fastest way to format JSON on a Mac is in Terminal: run jq . file.json. jq comes with macOS 15 Sequoia and later. On any version, python3 -m json.tool file.json works once Apple's Command Line Tools are installed. To format whatever is on your clipboard, run pbpaste | jq . | pbcopy.

These built-in options are free and run on your Mac. They do have limits. They reject broken JSON, and they don't let you click through the structure. An offline app is quicker for pasted JSON with comments or trailing commas, for browsing large documents, and for formatting from any app with a hotkey.

Format JSON on Mac with jq (the fastest built-in way)

jq is a command-line JSON processor, and it's already installed on macOS 15 Sequoia and macOS 26 Tahoe. To check your Mac, open Terminal and run:

bash
jq --version

This prints the installed jq version. If you get command not found, you're probably on macOS 14 Sonoma. In that case, install jq with a package manager such as Homebrew (brew install jq) or use Python (next section).

To pretty-print a file:

bash
jq . data.json

The . is a filter that means "the whole document." jq prints the result with 2-space indentation, colored in Terminal.

Useful variations:

bash
jq --indent 4 . data.json      # 4-space indentation
jq --tab . data.json           # indent with tabs
jq -S . data.json              # sort keys alphabetically
jq -c . data.json              # minify to one line
pbpaste | jq . | pbcopy        # format the clipboard and copy the result back

To save the formatted version to a new file:

bash
jq . data.json > data-pretty.json

Warning: never redirect jq's output to the file you're reading (jq . data.json > data.json). The shell empties the file before jq reads it, and you lose the contents. To format a file in place, write to a temporary file and then replace the original:

bash
jq . data.json > data.tmp && mv data.tmp data.json

Because of the &&, the original is replaced only if jq succeeds.

Other things to know about jq:

  • jq is strict. Comments, trailing commas and single quotes stop it with a parse error that names the line and column. See Fix JSON that won't parse.
  • jq handles NDJSON / JSON Lines. jq . events.ndjson formats each record in turn. jq -s . events.ndjson wraps them all into one array.
  • Color disappears when you pipe. To keep it in a pager, use jq -C . data.json | less -R.

Format JSON with python3 -m json.tool

Python includes a JSON formatter. On a fresh Mac, /usr/bin/python3 is a placeholder, and the first time you run it, macOS offers to install the Command Line Tools. Click Install, or run xcode-select --install yourself. After that:

bash
python3 -m json.tool data.json

The default indentation is 4 spaces. Options:

bash
python3 -m json.tool --indent 2 data.json         # 2-space indentation
python3 -m json.tool --sort-keys data.json        # alphabetical keys
python3 -m json.tool --compact data.json          # minify
python3 -m json.tool --no-ensure-ascii data.json  # keep é, 日本 etc. as-is
python3 -m json.tool --json-lines events.ndjson   # one record per line
pbpaste | python3 -m json.tool | pbcopy           # format the clipboard

Gotchas:

  • Non-ASCII text gets escaped. By default, café comes out as caf\u00e9. Add --no-ensure-ascii to keep the characters readable.
  • Numbers are re-printed from their parsed value. For example, 1.10 becomes 1.1. Check the output if the exact spelling of numbers matters.
  • Duplicate keys disappear without a warning. If an object has the same key twice, only the last value survives.
  • NDJSON needs --json-lines. Without it, Python stops at the second record with an "Extra data" error.

Can plutil format JSON?

plutil is the wrong tool for a .json file. It's Apple's property-list tool. Its JSON output is useful when your starting point is a .plist you want to read as JSON:

bash
plutil -convert json -r -o - settings.plist

This converts settings.plist to indented JSON (-r) and prints it in Terminal (-o -) without changing the file.

Warning: if you leave out -o -, plutil -convert overwrites the original file in the new format.

The conversion fails if the property list contains dates or binary data, because JSON has no types for them. For .json files, use jq or Python.

View JSON in a browser or code editor

In a browser, formatting usually means a web-based JSON formatter. That's fine for public sample data. The trade-off is that you paste your data into a site you don't control, and you need the page to load first. Don't paste tokens, customer records or production data into a site unless you know where it goes.

Visual Studio Code (free as of November 2026) is a full code editor with extensions, not a set of small JSON tools. If you already spend your day in it, it makes sense to look there first.

Format JSON offline in a Mac app

We make Bytepliers, a native Mac app of offline developer tools, so weigh this section accordingly. Its JSON Formatter covers what the Terminal tools don't:

  • It repairs broken JSON and lists each fix.
  • It marks errors inline.
  • It has a tree view.
  • It has a jq/JSONPath filter bar.

To format JSON in Bytepliers:

  1. Open Bytepliers and press ⌘1 (Command-1) to open JSON Formatter.
  2. Paste your JSON into the JSON pane, drop a file on it, or press ⌘O to open a file.
  3. Choose Format (the default) or Minify.
  4. Set Indent to 2 spaces (the default), 4 spaces or Tab. Turn on Sort Keys if you want keys in alphabetical order.
  5. Press ⇧⌘C (Command-Shift-C) to copy the result, or ⌘S to save it.
JSON Formatter with unquoted keys, single quotes and trailing commas on the left, strict JSON on the right and a Repaired 3 issues badge
Lenient mode repairs the input and says what it fixed.

Details worth knowing:

  • Number literals and key order are kept as written (unless you turn on Sort Keys), so 1.10 stays 1.10.
  • Text or tree. Switch the output to Tree to browse the document with Key / Value / Type columns. Click a segment of the path bar to select it, or ⌘-click it to copy its path.
  • Filter the result. The bar under the output takes a jq expression (for example .items[] | .name) or JSONPath, so you can format just the part you need.
  • NDJSON is detected. When several documents are separated by line breaks, choose One per line or Wrap as array.
  • From Finder: Control-click a .json file and choose Open With ▸ Bytepliers. Bytepliers never makes itself the default app. Its Quick Look extension also shows .json files pretty-printed and colored when you press Space in Finder.

Every option is listed in the JSON Formatter docs. Bytepliers is part of MacSuite, and every tool works during the 7-day free trial.

Fix JSON that won't parse

Most "invalid JSON" errors come from a handful of causes:

ProblemTypical sourceExample
Trailing commaHand-edited config, copied code{"a": 1,}
Commentstsconfig.json, other JSONC files// debug only
Single quotes or unquoted keysJavaScript object literals{name: 'x'}
Smart quotesText pasted through chat, notes or word-processing apps{“a”: 1}
Python or JavaScript valuesprint() output, logsTrue, None, undefined, NaN
JSON inside a stringLog lines, API fields"{\"a\":1}"

In Terminal, the error message points you to a position. For a trailing comma, Python says Expecting property name enclosed in double quotes, followed by a line and column just past the stray comma, where it expected the next key. jq reports a parse error with a line and column.

If the JSON is wrapped in a string, jq can unwrap it:

bash
pbpaste | jq 'fromjson'

This reads the clipboard as a JSON string, parses the text inside it, and prints the result formatted.

In Bytepliers, the JSON Formatter starts in Lenient mode, which repairs everything in the table above:

  • comments and trailing commas
  • single quotes and unquoted keys
  • True/False/None/undefined, NaN and Infinity
  • smart quotes
  • string-wrapped or backslash-escaped documents
  • raw control characters

A "Repaired N issues" badge opens a list of each fix with its line and column, and the output is strict JSON. Switch to Strict to validate against RFC 8259 only. Errors then get a red line, a dotted underline at the exact column, and a status line such as "Ln 3, Col 11". If Lenient mode could parse the input, a Switch to Lenient button appears.

Format JSON on the clipboard with a hotkey

Built-in: pbpaste | jq . | pbcopy reformats the clipboard in place. To run it from a key combination, you have to set that up yourself, for example as a shortcut in the Shortcuts app.

With Bytepliers, two global hotkeys work in any app. You can change both in Settings ▸ Shortcuts.

  • Quick Panel, ⌥⌘B (Option-Command-B). Copy some JSON and press the shortcut. A floating panel detects the JSON and shows it pretty-printed. Press ⏎ to copy the result and close the panel, or ⌘O to open it in the main window. To pick a different transform, start typing its name (for example "minify").
  • Detect & Replace Clipboard, ⌥⇧⌘B (Option-Shift-Command-B). This replaces the clipboard without opening a window. Multi-line JSON is minified, and single-line JSON is formatted. A small HUD confirms the change. To undo it, choose Tools ▸ Restore Previous Clipboard or use the menu bar icon.
Quick Panel with order JSON from the clipboard pretty-printed and JSON detection chips

The Quick Panel's Format JSON and Detect & Replace use the strict parser, so they don't repair broken JSON. For JSON with comments or trailing commas, use the JSON Formatter in the main window, where Lenient mode can fix it.

The hotkeys only work while Bytepliers is running. To keep them available, turn on Launch at login in Settings ▸ General. The Quick Panel docs cover the rest.

For scripts, Bytepliers also has a bytepliers command:

  1. Install it from Settings ▸ Integrations ▸ Command-Line Tool ▸ Install….
  2. Open Bytepliers once so the command is enabled.
  3. Run:
bash
pbpaste | bytepliers json-format | pbcopy

The command refuses input over 2 MB. See the bytepliers command-line tool docs.

Format very large JSON files

Size limits decide which tool to use:

ToolPractical limit
jq / python3Your Mac's memory, since each document is parsed in full before it's printed.
Bytepliers JSON Formatter64 MB of input. Files over 50 MB ask before opening. Syntax coloring turns off above about 400,000 characters. JSON nested deeper than 100 levels shows "Nesting too deep".
Bytepliers Quick Panel / Detect & ReplaceClipboard up to 1,000,000 bytes. The Quick Panel shows the first 20 KB / 400 lines, but ⏎ copies everything.
bytepliers command2 MB per input.
Finder Quick Look (Bytepliers extension)Files over 5 MB show only the first 256 KB.

For a file over 64 MB, use jq to pull out the part you need, then format or browse that:

bash
jq '.items[0:100]' huge.json > sample.json

This saves the first 100 elements of the items array to a smaller file. In the Bytepliers tree view, Expand All is turned off for documents with more than 60,000 values ("Too large to expand at once"), so open the branches you need one at a time.

Which method to use

MethodInstallFixes broken JSONClipboardBest for
jq .Built in on macOS 15+Nopbpaste pipeFast formatting, scripts, huge files
python3 -m json.toolCommand Line ToolsNopbpaste pipeMacs without jq
plutil -convert json -rBuilt inNoNoReading .plist files as JSON
Web formatterNoneDepends on the sitePastePublic sample data only
Bytepliers JSON FormatterPart of MacSuite ($349 one-time as of November 2026), 7-day trialYes, with a list of fixesGlobal hotkeys, CLIMessy JSON, browsing, filtering, daily use

If you format JSON a few times a month, jq or Python is enough. If you paste API responses, logs and configs all day, an app saves you the round trips. Our best JSON viewers for Mac roundup covers more options.

If it doesn't work

  • jq: command not found. You're on macOS 14 or earlier. Install jq, or use python3 -m json.tool.
  • A dialog asks to install developer tools when you run python3. That's expected on a fresh Mac. Click Install, and run the command again when the install finishes.
  • The output file is empty. You redirected the output to the input file. Restore the file from a backup (Time Machine, Git), and next time use the temporary-file pattern from the jq section.
  • Accented or non-Latin characters show as \u00e9. Python escapes them by default. Add --no-ensure-ascii.
  • parse error or "Expecting property name…". The JSON is invalid. Check it against the causes in Fix JSON that won't parse.
  • Bytepliers says "the limit for live conversion is 2 MB". You hit that limit in the command-line tool, a pipeline or the Compact Overlay. Open the file in the JSON Formatter instead, which accepts up to 64 MB.

FAQ

Does macOS have a built-in JSON formatter? Not as an app. In Terminal, macOS 15 Sequoia and later include jq. On any version, python3 -m json.tool works once the Command Line Tools are installed.

How do I minify JSON on a Mac? Run jq -c . file.json or python3 -m json.tool --compact file.json. In Bytepliers, choose Minify in JSON Formatter.

Is formatting JSON this way private? Yes. jq, Python, plutil and Bytepliers's JSON Formatter all format on your Mac without uploading anything. Web-based formatters are the exception: depending on the site, your data may be sent to it.

Every app.
One purchase.