How to format JSON on a Mac without a website

Pretty-print or validate JSON on your Mac offline: jq and Python in Terminal, your code editor, or one click from the clipboard in the MacBook notch.

By Rudra Satani, maker of NotchMind ·

Pasting an API response or a config file into an online formatter is quick, but it sends your data to someone else’s server, tokens and all. Your Mac can format JSON without leaving it.

In Terminal with jq

Recent versions of macOS include jq. If yours doesn’t, install it with Homebrew (brew install jq). To format whatever is on the clipboard and copy it back:

pbpaste | jq . | pbcopy

jq also tells you exactly where invalid JSON breaks.

In Terminal with Python

If Python 3 is installed (macOS offers to install it with the developer tools the first time you run python3):

pbpaste | python3 -m json.tool | pbcopy

In your editor

VS Code, Zed, Nova and most code editors format JSON with their Format Document command. Paste into a new file, set the language to JSON and format.

From the notch

NotchMind, which I make, recognizes JSON when you copy it and offers Format JSON right away: one click and the clipboard holds the pretty-printed version. Its Developer Tools page also validates and minifies JSON, and works offline. See developer tools in the notch.

Which to use

For one-off checks, copy it and use the notch or jq. For files you edit, use your editor. Avoid pasting JSON with keys or personal data into websites.

About the author

Rudra Satani makes NotchMind, a notch app for Mac, so read anything about notch apps here with that in mind. Spotted a mistake? Email support@notchmind.com, or reach out at @rudraxx13.