How to use JSON Formatter
- Paste JSON into Input JSON, or select Try sample. The sample includes a large integer and an escaped character so you can see how they are preserved. Input is limited to 100,000 UTF-16 code units.
- Choose 2 spaces, 4 spaces, or tabs and select Format JSON. Use Minify to remove whitespace outside strings, or Validate to check syntax while retaining the input editor’s whitespace.
- Review the result, syntax errors, and any warnings about duplicate keys or numeric ranges. Correct invalid input and run the action again. Changing indentation immediately updates an existing formatted result.
- Select Copy result or Download .json to export the result. Editing the input clears the old result and disables export until you run another action. Clear empties both editors while keeping your indentation choice.
Questions about this tool
How do I format or beautify JSON?
Paste JSON, choose an indentation style, and select Format JSON. Objects and arrays are expanded with line breaks and indentation, while empty containers stay compact. The formatter keeps every original token: it does not sort keys, change string escapes, normalize numbers, or remove duplicate keys. The input editor stays unchanged beside the formatted result.
What is the difference between Format, Minify, and Validate?
Format JSON adds line breaks and indentation outside strings. Minify removes whitespace outside strings, preserving spaces inside string values. Validate checks JSON syntax and places the input editor’s text into the result without reformatting. All three actions reject invalid syntax. Validation does not check a JSON Schema, required application fields, or an API contract.
Will large JSON integers lose precision?
The output uses original source tokens, so numbers such as 9007199254740993, 1.00, -0, and 1e+3 retain their exact spelling. JSON.parse checks syntax, but its parsed values are discarded. The tool warns when a number exceeds JavaScript’s safe integer or finite range, or a nonzero value underflows to zero. Decimal values can also be approximated by downstream readers. Formatting cannot change how another application stores numbers.
What happens to duplicate keys and key order?
Every key remains in its original position, including numeric-looking names and duplicates. A warning counts repeated names within each object. Escaped spellings are decoded for this comparison, so "name" and "\u006eame" count as the same name. Separate objects have separate key sets. JSON.parse retains the last value for duplicate names; other readers may behave differently, so review duplicates before sharing data.
Which JSON values and syntax are supported?
Objects, arrays, strings, numbers, true, false, and null are supported, including top-level scalar values such as 42 or a quoted string. JSON requires double-quoted property names and strings. Comments, trailing commas, single quotes, undefined, NaN, and Infinity are rejected. Exponent notation such as 1e400 is valid JSON syntax, even when a particular reader cannot represent its numeric value.
Can the formatter fix malformed JSON automatically?
No. Invalid input stays in the editor and the previous result is cleared. The error message comes from your browser’s JSON parser. When it reports a character position, the tool derives a one-based line and column; an engine-provided line and column can also be shown. Otherwise it explicitly says an exact location is unavailable. Error wording varies by browser, and derived columns count UTF-16 code units.
Are whitespace, Unicode, and string escapes preserved?
Formatting changes only whitespace between JSON tokens. String contents and escape spellings, including escaped Unicode characters, are preserved. Browser text editors normalize CRLF and CR line endings to LF, so Validate preserves editor text rather than original file bytes. Raw unpaired UTF-16 surrogates are rejected because UTF-8 downloads would replace them. Write those values as JSON Unicode escapes, such as \uD800, to preserve their spelling.
What are the size and nesting limits?
Input is limited to 100,000 UTF-16 code units, nested objects and arrays to 100 levels, and formatted output to 1,000,000 code units. UTF-16 units differ from visible characters: many emoji use two or more. Oversized paste and drop text is rejected instead of silently truncated. A drop is checked conservatively against the current text length. If indentation would make output too large, try Minify. These are tool limits, not JSON grammar rules.
Is my JSON uploaded or stored?
No. JSON processing runs in this tab without uploading input, saving it in browser storage, or downloading a processing library. Copy result writes to the clipboard only when you activate it; if clipboard access fails, select and copy the result manually. Download .json creates a UTF-8 application/json file. Clear or leaving this tool clears its working text; files and clipboard contents you already exported remain on your device.