JSON Formatter
Format and validate JSON
About JSON Formatter
JSON Formatter checks your JSON with the browser's JSON.parse, then re-indents the text you pasted instead of rebuilding it from parsed values. That is why 20-digit IDs and 1.10 stay exactly as written, and so do escapes unless you sort the keys. Choose 2 spaces, 4 spaces, or a tab, check Sort keys A–Z to order the keys of every object at every depth, or use Minify for a single line. Invalid JSON is reported with its line and column, and the faulty line is shown with a caret under the problem. There is no tree view and no syntax coloring. Validation and re-indenting run in your browser.
Example
Format with 2 spaces: the 20-digit ID and 1.10 are copied, not recalculated.
Input
{"id":12345678901234567890,"price":1.10,"tags":["a","b"],"meta":{}}Output
{
"id": 12345678901234567890,
"price": 1.10,
"tags": [
"a",
"b"
],
"meta": {}
}How to format and validate JSON
- 1Paste JSON into "Input".
- 2Choose "2 spaces", "4 spaces", or "Tab" under Indent, and check "Sort keys A–Z" if you want ordered keys.
- 3Click "Format", or "Minify" for a single line.
- 4If the JSON is invalid, read the red line under the boxes: it gives the line and column, and the block below marks the spot with ^.
- 5Click "Copy", or "Download" to save "formatted.json".
Formats and limits
- Input
- JSON text, pasted
- Output
- Indented or one-line JSON, saved as formatted.json
- Indent
- 2 spaces, 4 spaces, or a tab
- Sort keys A–Z
- Every object at every depth, by character code (capitals first); numbers kept, strings re-escaped
- Length
- The code sets no maximum; above 1,000,000 characters the boxes show only the first 20,000 characters
Where your JSON is processed
JSON.parse and the re-indenter are part of the page, so formatting and validation take place in your browser and your JSON is not uploaded. If an Invalid JSON message is displayed, that message, with the quoted part of your JSON, long numbers, and addresses removed, is reported to our error log, together with the tool name and your browser's name and version.
Frequently asked questions
Does it show where my JSON is invalid?
Yes. Click "Format" and the message gives the line and column of the first error, while the box below shows that line with a caret under the problem. Trailing commas, single quotes, and unquoted keys are the usual causes.
Will formatting change my numbers?
No. The output is built from your original text, so 12345678901234567890 and 1.10 are copied as typed, whereas re-serializing would print 12345678901234567000 and 1.1. With Sort keys A–Z, numbers stay exact but escapes such as \u00e9 are rewritten as the character.
Does Sort keys A–Z ignore case?
No. Keys are ordered by character code at every depth, so capitals come first: B sorts before a. If a key appears twice in one object, only its last value is kept. Arrays keep their original order.
Is there a tree view?
No. The output is plain text in a box, with no collapsible tree and no colors. The indentation, and the caret shown for an error, are the only guides.
Tips and tricks
- ✓A JSON file that starts with a byte order mark is rejected here as invalid; JSON Minifier and Code Formatter remove that mark first.