# JSON Formatter Guide

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

- Tool: https://ilham.dev/tools/json-formatter/
- Guide URL: https://ilham.dev/guides/json-formatter/
- Tool guides index: https://ilham.dev/guides/tools/
- Broader guide: Working With Structured Data (https://ilham.dev/guides/working-with-structured-data/)

## 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.

## Use the tool

Open https://ilham.dev/tools/json-formatter/, add the input the tool asks for, run it, and check the output before using it elsewhere.

## Input and output

- Input: JSON text.
- Output: JSON text.
- Category: Formats.

## Privacy and processing
Processing happens locally in your browser. This tool does not upload the input to ilham.dev.

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

## Limitations
- Sorting only changes object keys
- Array order is preserved

## 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.