# JSON formatter

> Pretty-print, minify, and validate JSON, with the exact line and column when it fails.

Free JSON formatter and JSON validator that runs in the browser. Choose an indent of 2, 4, or a tab, sort object keys, minify, and read a tree of the value. Invalid JSON reports the line, the column, and the line of source.

- Page: https://benchline.fabwaseem.com/t/json-formatter
- Runs: in the browser. Input stays on the device.
- Price: free, no account
- Input: JSON text, an indent of 2, 4, or tab, and toggles for minify and sort keys.
- Output: Formatted or minified JSON, a tree of the value, or the line and column of the first syntax error.
- Keywords: json formatter, json validator, json minify, json pretty print
- Updated: 2026-10-18
- Built by: Waseem Anjum (https://fabwaseem.com)

## How to use it

1. **Paste JSON.** Drop a payload, a config file, or a response body into the editor. Nothing is uploaded.
2. **Pick pretty or minify.** Pretty uses 2 spaces, 4 spaces, or a tab. Minify removes the insignificant whitespace. Sort keys when you want a stable order.
3. **Read the error or the tree.** An invalid document names the line and column. A valid one can be copied, downloaded, or opened as a tree.

## Use it from an AI agent

MCP tool name: `format_json`
MCP endpoint: https://benchline.fabwaseem.com/mcp (Streamable HTTP, no key)
HTTP: POST https://benchline.fabwaseem.com/api/v1/tools/json-formatter with the input as the JSON body
This call does not fetch anything. It runs on the arguments you send.

Pretty-print or minify JSON. A number that does not fit in a JavaScript number keeps the digits you sent. Returns the formatted text when it is valid, or the line and column of each syntax error.

### Input schema

```json
{
  "type": "object",
  "properties": {
    "json": {
      "type": "string",
      "description": "JSON text to format or validate."
    },
    "indent": {
      "default": "2",
      "type": "string",
      "enum": [
        "2",
        "4",
        "tab"
      ]
    },
    "sortKeys": {
      "default": false,
      "description": "Sort object keys. Array order is kept.",
      "type": "boolean"
    },
    "minify": {
      "default": false,
      "type": "boolean"
    }
  },
  "required": [
    "json",
    "indent",
    "sortKeys",
    "minify"
  ],
  "additionalProperties": false
}
```

### Example tools/call

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "format_json",
    "arguments": {
      "json": "{}",
      "indent": "2",
      "sortKeys": false,
      "minify": false
    }
  }
}
```

Setup for Claude, Cursor, and VS Code: https://benchline.fabwaseem.com/mcp/guide

## Questions

### Does this upload my JSON?

No. Formatting and validation run in the browser. The document is not posted and it is not stored.

### How exact is the error position?

The parser reports the first problem at a line and column, counted from 1, plus the source line. A trailing comma, a comment, and a truncated value each get their own position.

### What does sort keys change?

Object keys are ordered by UTF-16 code unit. Array order stays as written. Nested objects are sorted too.

### Will comments or trailing commas pass?

No. This checks strict JSON. Comments and trailing commas are reported as errors instead of being stripped.

### Do large integers stay exact?

Yes. A number that does not fit in a JavaScript number, such as an id past 2^53 or a long decimal, is printed with the digits you pasted. A number that does fit is still written in ordinary JSON form, so 1.0 becomes 1.

## Related tools

- [JSON YAML converter](https://benchline.fabwaseem.com/t/json-yaml-convert): Convert JSON, YAML, TOML, and XML in the browser, and keep the line number when a document fails.
- [CSV JSON converter](https://benchline.fabwaseem.com/t/csv-json-convert): Convert CSV to JSON and JSON back to CSV, with a delimiter and a header row you choose.
- [Base64 codec](https://benchline.fabwaseem.com/t/base64-codec): Encode and decode Base64 for text or a file, including the URL-safe alphabet.
- [JWT decoder](https://benchline.fabwaseem.com/t/jwt-decoder): Paste a JSON Web Token, read the claims, and verify the signature in the browser.
