How to Format JSON on Mac
Pretty-print messy or minified JSON on Mac without pasting it into a website. Use the Format JSON extension for Raycast, or jq and Python in Terminal.
Pretty-print messy or minified JSON on Mac without pasting it into a website. Use the Format JSON extension for Raycast, or jq and Python in Terminal.
You copied a response from an API or a log line, and it's one long line of brackets and quotes. You need to read it, and you'd rather not paste it into a random website.
The short answer: install the free Format JSON extension for Raycast, copy the JSON and run Format Clipboard JSON. Paste, and it's indented. Without installing anything, run pbpaste | python3 -m json.tool in Terminal.
| Method | Works from | Handles escaped JSON | Stays on your Mac |
|---|---|---|---|
| Format JSON for Raycast | Clipboard, editor selection | Yes | Yes |
python3 -m json.tool | Terminal | No | Yes |
jq | Terminal | With fromjson | Yes |
| Online formatters | Browser | Some | No |
Format JSON works on what you've already got: the JSON on your clipboard, or the JSON selected in your editor. It also accepts JavaScript objects with unquoted keys, and it parses stringified JSON before formatting it.
Copy the JSON, open Raycast and run Format Clipboard JSON. The formatted version replaces what's on your clipboard, ready to paste.

All the commands:
In the preferences, choose the Indentation: a tab, or 2, 4 or 8 spaces.
Format JSON works on Windows too.
macOS can format JSON in Terminal without anything extra.
With Python, which comes with the Xcode Command Line Tools:
pbpaste | python3 -m json.tool
Add | pbcopy to the end to put the result back on your clipboard. Use --indent 2 for two spaces instead of four.
With jq, which ships with recent versions of macOS and is also on Homebrew:
pbpaste | jq .
jq can do much more than format. jq -c '.[]' turns an array into JSON Lines, and jq '.items[0].name' pulls out a single value.
Online JSON formatters work, but they send your text to someone else's server. API responses often contain tokens, email addresses or customer data. Formatting locally, in Raycast or in Terminal, keeps it on your Mac.
Here's a quick tour of what else it can do, in under seven minutes:
Copy the JSON and run pbpaste | python3 -m json.tool in Terminal. On recent versions of macOS, jq is also built in: pbpaste | jq .
Not if it contains tokens, customer data or anything private. The text is sent to someone else's server. Formatting locally, in Raycast or Terminal, keeps it on your Mac.
Format JSON for Raycast detects stringified JSON, like an object stored inside a string with escaped quotes, parses it and formats the result.
Run Format Array of JSON to JSONLines in Raycast and paste the array. In Terminal, jq -c '.[]' does the same.
Format JSON from your clipboard with one hotkey. Try Raycast with the free Format JSON extension.
Download
More guides
Type with your voice in any app on your Mac. How to turn on the built-in macOS dictation, and how Raycast Dictation turns speech into clean, formatted text that fits the app you're in.
Fix typos and grammar in any app on your Mac with one hotkey. How Raycast's Quick Fix works, what macOS can do on its own, and how it compares with Grammarly.
Paste text without the fonts, colors and links it came with. The Mac shortcut for paste and match style, which apps support it, and how to always paste plain text with Raycast.
Check your download speed, upload speed and ping on Mac without opening a browser. Use the built-in networkQuality command or a Speedtest by Ookla test from Raycast.
