JSON formatter
Format, minify and validate JSON in the browser: choose 2/4-space or tab indentation, sort keys, get exact line/column error positions, and see key count, nesting depth, characters and bytes.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
String escape / unescape
Turn plain text into a JSON string literal, or decode escapes such as \n and \uXXXX back to text. Input wrapped in double quotes is parsed as a JSON string literal.
What this tool does
- Pretty-print a wall of minified JSON from an API response so you can see the nesting and pick the field you need.
- Validate JSON before committing a config or a fixture: syntax errors are reported with the exact line and column instead of making you count brackets.
- Normalise before comparing: enable "sort keys" so fields line up in dictionary order, which makes a manual diff far easier.
- Embed data in ASCII-only config: escape non-ASCII text to \uXXXX, or decode \n and \uXXXX sequences back into readable text.
Example
Input
{"name":"UniKit","version":2,"tags":["json","formatting"],"meta":{"stable":true,"score":9.5}}Output
{
"name": "UniKit",
"version": 2,
"tags": [
"json",
"formatting"
],
"meta": {
"stable": true,
"score": 9.5
}
}Indentation is 2 spaces. The statistics below the output read: 6 keys, maximum depth 2, 138 characters, 138 bytes — the payload is pure ASCII, so characters and bytes match.
Frequently asked questions
Does key sorting work recursively?
Yes. Object keys at every level are re-sorted in dictionary order (JavaScript default string comparison) while array element order is preserved. Nested objects are sorted too, which is exactly what you want before comparing two documents.
Why does the error report only one position?
Parsing stops at the first syntax error, so only that one is reported. Common causes are an unexpected end (unclosed bracket or quote), an object key that is not double-quoted, a missing colon after a key, or extra content after the JSON value. Fix that spot and parse again to see the next one.
How are the key count and nesting depth computed?
The key count adds up object keys across all levels and ignores array elements. Maximum depth counts the root container as level 1, so {"a":[1]} has depth 2, and a scalar root has depth 0. Characters are the length of the output text while bytes are the UTF-8 size, so text containing Chinese has noticeably more bytes than characters.
How is this minify different from the JSON minify tool?
This minify only strips whitespace and newlines to produce a single-line document; it does not compress data, so the size saving is modest. For smaller transfers use a real compression algorithm such as gzip or brotli, or switch to a line-based format like JSON Lines.
How do I use the string escape panel?
It turns plain text into a valid JSON string literal with surrounding double quotes, or decodes escapes such as \n, \t and \uXXXX back into real characters. Input that already has surrounding quotes is parsed as a JSON string literal. Tick "write non-ASCII as \uXXXX" to turn Chinese characters into escape sequences for ASCII-only config files.
Keywords:jsonjson 格式化json formatterjson 美化json beautifyjson 校验json validator键排序sort keysminify