Pretty-print minified JSON
{"name":"dev247","tools":["json","base64"],"free":true}{
"name": "dev247",
"tools": [
"json",
"base64"
],
"free": true
}Two-space indentation, one value per line.
Format, validate and pinpoint syntax errors, even in 50MB+ files.
.json file onto it. Small inputs are checked as you type; for very large files press Format.$.users[0].email.{"name":"dev247","tools":["json","base64"],"free":true}{
"name": "dev247",
"tools": [
"json",
"base64"
],
"free": true
}Two-space indentation, one value per line.
{"name": "dev247", "free": true,}✗ Line 1, column 32: Trailing comma: remove the "," before "}"
Trailing commas are allowed in JavaScript but not in JSON. The most common JSON error.
{
// settings
name: 'dev247',
tags: ['a', 'b',],
}{
"name": "dev247",
"tags": [
"a",
"b"
]
}Try to fix removed the comment and trailing commas, and quoted the keys and strings.
{
"id": 1,
"tags": ["a", "b"]
}{"id":1,"tags":["a","b"]}All unnecessary whitespace removed, ready for an API request or config value.
JSON (JavaScript Object Notation) is a text format for structured data: objects in curly braces, arrays in square brackets, and strings, numbers, true, false and null as values. It is the standard format for APIs, configuration files and data exchange, defined in RFC 8259. JSON looks like JavaScript, but its rules are much stricter, which is where most errors come from.
| Rule | Valid | Invalid |
|---|---|---|
| Strings use double quotes | "name" | 'name' |
| Property names are quoted | {"id": 1} | {id: 1} |
| No trailing commas | [1, 2] | [1, 2,] |
| No comments | (none) | // note, /* note */ |
| Lowercase literals | true, false, null | True, None, undefined |
| Plain decimal numbers | 10, -1.5e3 | 010, .5, NaN, 0xFF |
| Escaped special characters | "line\nbreak" | a real line break inside a string |
Most online formatters run JSON.parse and JSON.stringify. That has two hidden problems: numbers larger than 253 (such as 64-bit IDs from Twitter, Discord or databases) are silently rounded, and the error message often gives no line number. This tool formats JSON token by token instead, so large numbers, key order and even duplicate keys stay exactly as they were, and its own validator reports the exact line and column with a clear explanation.
Sort keys and the Tree view do need to parse the data into JavaScript values. If your JSON contains numbers that would change, the tool tells you.
Many config files are not strict JSON. tsconfig.json and VS Code settings use JSONC (JSON with comments), and JSON5 also allows trailing commas, single quotes, unquoted keys and hex numbers. They are convenient for humans but rejected by JSON.parse and most APIs. The Try to fix button reads JSON5 (plus Python's True, False and None) and writes strict JSON.
const pretty = JSON.stringify(JSON.parse(text), null, 2); // formatconst compact = JSON.stringify(JSON.parse(text)); // minifyjq . data.json # format and validatejq -c . data.json # minifyjq -S . data.json # sort keyspython3 -m json.tool data.jsonpython3 -m json.tool --sort-keys --indent 4 data.jsonecho json_encode(json_decode($json), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); json_validate($json); // PHP 8.3+: true / false without decodingUnexpected token } in JSON or "Trailing comma"
There is a comma after the last item of an object or array. Remove it, or press Try to fix.
Unexpected token ' in JSON
JSON strings and property names need double quotes. Replace single quotes with double quotes, or press Try to fix.
Unexpected token / in JSON
The file contains comments, which JSON does not allow. Remove them, or press Try to fix (common with tsconfig.json and other JSONC files).
Unexpected end of JSON input
The JSON is cut off: a closing } or ] is missing, or the response was empty. Check that you copied everything and that the API actually returned data.
Large IDs change after formatting in other tools
Numbers above 9,007,199,254,740,991 cannot be stored exactly in JavaScript. This tool keeps them exact in the Text view. In your own code, send such IDs as strings.
Paste it here. The message under the tool gives the line and column, shows the line with a caret under the problem, and Show me moves the cursor straight to it.
Yes, for the most common problems: comments, trailing commas, single quotes, unquoted property names and Python's True, False and None. Press Try to fix when the JSON is invalid.
Files up to 200 MB can be loaded. Inputs over 2 MB are formatted when you press Format instead of on every keystroke, so typing stays fast.
No. The Text view only changes whitespace: values, key order, large numbers and duplicate keys stay exactly the same.
A way to point at one value inside a document, such as $.users[0].email. Click any key in the Tree view to see and copy its path for jq, JSONPath or your code.
No. Formatting, validation and the tree view all run in your browser, so it is safe to paste API responses with tokens or personal data.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.