# How to Format JSON on Mac

URL: https://www.raycast.com/guides/how-to-format-json-on-mac
Published: 2026-11-18
Updated: 2026-11-18
Description: 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](https://www.raycast.com/destiner/json-format) 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 with Raycast | The quickest way

### [Format JSON: pretty-print JSON from anywhere](https://www.raycast.com/destiner/json-format)

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.

![Format Selected JSON and Show opens the formatted JSON in a viewer.](https://www.raycast.com/uploads/how-to-format-json-on-mac/how-to-format-json-on-mac.png)

> Pro tip: give **Format Clipboard JSON** a [hotkey](https://manual.raycast.com/command-aliases-and-hotkeys) and turn on **Auto Paste** in the extension's preferences. Then select messy JSON in any editor, copy, press the hotkey, and it's replaced with the formatted version.

All the commands:

- **Format Clipboard JSON**: formats your clipboard and copies (or pastes) the result.
- **Format Selected JSON**: formats the JSON selected in the frontmost app and replaces it.
- **Format Selected JSON and Show**: formats the selection and opens it in a viewer, for when you just want to read it.
- **Format JSON**: paste JSON into a text field and format it there.
- **Format Array of JSON to JSONLines**: turns an array of objects into JSON Lines, one object per line.
- **Format Text into Valid JSON Value**: wraps text in double quotes and escapes it, so you can drop it into a JSON file.

In the preferences, choose the **Indentation**: a tab, or 2, 4 or 8 spaces.

Format JSON works on Windows too.

## Use Terminal | Built in

macOS can format JSON in Terminal without anything extra.

With Python, which comes with the Xcode Command Line Tools:

```bash
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:

```bash
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.

## Why not an online formatter?

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.

## New to Raycast?

Here's a quick tour of what else it can do, in under seven minutes:

[Video: 102 Things You Can Do With Raycast 2.0](https://www.youtube.com/watch?v=G7_7F_FBqQE)

## Frequently Asked Questions

### How do I pretty-print JSON on Mac without installing anything?

Copy the JSON and run `pbpaste | python3 -m json.tool` in Terminal. On recent versions of macOS, `jq` is also built in: `pbpaste | jq .`

### Is it safe to paste JSON into an online formatter?

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.

### How do I format stringified or escaped JSON?

Format JSON for Raycast detects stringified JSON, like an object stored inside a string with escaped quotes, parses it and formats the result.

### How do I convert a JSON array to JSON Lines?

Run **Format Array of JSON to JSONLines** in Raycast and paste the array. In Terminal, `jq -c '.[]'` does the same.
