# JSON Formatter

Validate, pretty-print and minify JSON, with optional key sorting.

## URL

https://ilham.dev/tools/json-formatter/

## What It Does

Paste JSON and this validates it, pretty-prints it at the indentation you choose, or minifies it back down. The optional sort control reorders object keys at every level, ascending or descending, while leaving array order alone — which is exactly what you want when two API responses differ only in key order. Parsing uses the browser's own JSON parser, so it fails on exactly what a real parser fails on.

## Features

- Format JSON
- Validate JSON syntax
- Minify JSON
- Sort object keys
- Show parse errors

## Input

JSON text input.

## Output

JSON text output.

## Privacy

Processing happens locally in the browser.

No input data is uploaded to ilham.dev.

- Requires login: false
- Requires API key: false
- Stores user data: false


## Use Cases

- Debug API responses
- Format JSON configuration files
- Validate JSON syntax before pasting into an application
- Minify JSON for compact storage or transport

## Examples

- Does sorting also reorder arrays?
- What is the difference between this and the JSON Viewer?
- Is my data uploaded anywhere?


## Limitations

- Sorting only changes object keys
- Array order is preserved


## Related Tools

- https://ilham.dev/tools/json-minifier/
- https://ilham.dev/tools/json-viewer/
- https://ilham.dev/tools/json-to-yaml/


## Questions

### Does sorting also reorder arrays?

No, and that is deliberate. Only object keys are reordered. Array order is data, so changing it would change the meaning of the document.

### What is the difference between this and the JSON Viewer?

This one gives you text you can copy and paste. The viewer renders a collapsible tree, which is better for finding your way around a document whose shape you do not know yet.

### Is my data uploaded anywhere?

No. Parsing happens locally with JSON.parse and nothing leaves the browser.

