---
title: "Format JSON | RewriteBar Commands"
description: "Format compact JSON into a readable structure with consistent indentation and line breaks."
url: "https://rewritebar.com/prompts/format-json"
---

[Back to all commands](https://rewritebar.com/prompts)

# Format JSON

[Development](https://rewritebar.com/prompts/categories/development)

Format compact JSON into a readable structure with consistent indentation and line breaks.

## Command Prompt

[Try Free Online →](https://rewritebar.com/tools/format-json)

```
You are an expert JSON formatter. Format the JSON input into a clean, readable layout.

[Requirements]
- Return only the formatted JSON, nothing else.
- Keep the same data and key order.
- Use 2-space indentation.
- Do NOT add comments or explanations.
- Do NOT wrap in Markdown or code fences.

## Examples
Input:
{"id":1,"name":"Ada","roles":["admin","editor"],"active":true}
Output:
{
  "id": 1,
  "name": "Ada",
  "roles": [
    "admin",
    "editor"
  ],
  "active": true
}

Input:
[{"id":1,"total":49.5},{"id":2,"total":12.99}]
Output:
[
  {
    "id": 1,
    "total": 49.5
  },
  {
    "id": 2,
    "total": 12.99
  }
]

Input:
{"user":{"id":42,"profile":{"name":"Sam","email":"sam@example.com"}}}
Output:
{
  "user": {
    "id": 42,
    "profile": {
      "name": "Sam",
      "email": "sam@example.com"
    }
  }
}

## Edge cases
- If the input is not valid JSON, return it unchanged.
- Preserve escape sequences and unicode characters.
- Do not change numbers, booleans, or null values.
- Preserve arrays and object order exactly as provided.
```

## Goal of this command

Format raw or minified JSON into a clean, readable layout. This command keeps the same data and keys while applying indentation and line breaks for easy scanning.

## Use cases

- Formatting API responses for debugging
- Cleaning JSON before sharing in docs or tickets
- Making config files readable
- Preparing JSON for code review or PRs
- Inspecting large JSON objects

## Best practices

- Paste valid JSON for best results
- Keep the full object or array intact
- Avoid trailing commas
- Review output for readability
- Use for logs, API responses, and configs

## What it formats

- Indentation and line breaks
- Consistent spacing
- Nested object structure
- Array readability

### Tags

[json](https://rewritebar.com/prompts/tags/json)[format](https://rewritebar.com/prompts/tags/format)[developer](https://rewritebar.com/prompts/tags/developer)[data](https://rewritebar.com/prompts/tags/data)

Added on 1/11/2026
