JSON Formatter
Validate, beautify or minify JSON live — with error pinpointing, a tree view and structure charts.
How JSON Formatter calculator works?
The JSON Formatter works in 5 steps: it parses the input, pinpoints syntax errors, re-prints the data with your indent, measures the structure and compares sizes. JSON (JavaScript Object Notation) is the text data format defined in RFC 8259.
- 1
Parse the input
The browser JSON parser reads the input 120 milliseconds (ms) after you stop typing.
- 2
Pinpoint errors
A strict scanner walks the text character by character and reports the line and column of the first invalid character, with a 5-line snippet and a caret.
- 3
Re-print the data
JSON.stringify writes the data back with 2 spaces, 4 spaces, tabs or no whitespace (minified). “Sort keys” orders object keys A–Z at every level.
- 4
Measure the structure
A tree walk counts keys, values of 6 types (object, array, string, number, boolean, null) and nodes at each nesting depth.
- 5
Compare sizes
The Blob API measures 3 versions in UTF-8 bytes: your input, the minified output and the 2-space output.
JSON Formatter formula
The JSON Formatter uses 4 measurements: total values, maximum depth, UTF-8 byte size and minification saving. The examples use the built-in sample file.
Total values
- V
- Every node in the document, root included
- Keys
- Counted separately: names inside objects
Maximum depth
- D
- Deepest nesting level
UTF-8 byte size
- 1 byte
- ASCII, U+0000–U+007F (a, 7, {)
- 2 bytes
- U+0080–U+07FF (é, ß, Arabic, Hebrew)
- 3 bytes
- U+0800–U+FFFF (most Chinese, Japanese, Korean, Hindi)
- 4 bytes
- U+10000 and above (emoji)
Minification saving
- pretty
- Size with 2-space indent
- minified
- Size with no whitespace
JSON Formatter conversion chart
The JSON Formatter conversion chart maps the 6 JSON data types to JavaScript, Python and PHP types, and lists the 9 escape sequences JSON strings accept.
| JSON type | Example | JavaScript | Python | PHP |
|---|---|---|---|---|
| object | { "a": 1 } | Object | dict | array / stdClass |
| array | [1, 2] | Array | list | array |
| string | "text" | String | str | string |
| number | 42, 3.14, 1e6 | Number | int / float | int / float |
| boolean | true, false | Boolean | bool (True / False) | bool |
| null | null | null | None | null |
| Escape | Meaning | Example |
|---|---|---|
\" | Double quote | "say \"hi\"" |
\\ | Backslash | "C:\\Users" |
\/ | Forward slash (optional) | "a\/b" |
\b | Backspace | U+0008 |
\f | Form feed | U+000C |
\n | Line feed (new line) | "line 1\nline 2" |
\r | Carriage return | U+000D |
\t | Tab | "a\tb" |
\uXXXX | Any character by code point | "\u00e9" → é |
JSON Formatter FAQ
Is my JSON uploaded to a server?
Why is my JSON invalid?
Does JSON allow comments?
// or /* */ cause a parse error. JSONC and JSON5 are JSON variants that accept comments.What is the difference between formatting and minifying JSON?
Does sorting keys change my data?
Does the JSON Formatter keep large numbers exact?
"id": "9007199254740993".