JSON Formatter & Validator - Pretty Print, Minify, Validate
Developer Tools
Format, validate, and minify JSON in your browser. Sort keys, inspect a collapsible tree, and import or download .json files privately.
Paste JSON above to format, validate, or explore it.
How to use this tool
- Paste your JSON. Paste or type JSON, open a local .json file, or drop a file into the input box. The formatter accepts objects, arrays, strings, numbers, booleans, and null.
- Choose an indent style. Select 2 spaces (default), 4 spaces, tabs, or Minified. Minified removes all unnecessary whitespace for compact output.
- Optionally sort keys. Enable "Sort keys" to alphabetically sort all object keys at every nesting level. Useful for diffing or normalizing JSON.
- View output and stats. Copy or download formatted JSON, or explore it in the collapsible tree. Expand or collapse all tree nodes for smaller inputs. Stats show object count, array count, key count, nesting depth, character counts, and UTF-8 sizes.
What does a JSON formatter do?
A JSON formatter takes raw, often compressed or inconsistently indented JSON text and re-serializes it with consistent indentation. The result is easier to read, diff, and debug. This formatter supports 2-space and 4-space indentation (the two most common styles in JavaScript projects), tab indentation (common in Go and other languages), and minification (useful for shrinking payloads for HTTP requests or storage).
JSON validation and error location
Validation is performed by the browser's native JSON.parse: the same parser your
JavaScript runtime uses. When the input is invalid, the parser throws a
SyntaxError containing a character position (in V8/Chrome/Node) or a line and column
number (in Firefox/SpiderMonkey). This formatter extracts that information and displays it as a
human-readable "Line X, column Y" message, making it much faster to locate the offending character
in large JSON documents.
Key sorting
Enabling Sort keys reorders every object's properties alphabetically at every level of nesting. This is useful for producing deterministic JSON output, for example when comparing two API responses that contain the same data in different key orders, or when diffing configuration files. Sorting is applied before formatting, so the output is fully deterministic regardless of the original key order.
Tree view
The Tree view tab renders the parsed JSON as a collapsible tree. Each object and array can be expanded or collapsed independently. Objects show their key count and arrays show their element count in the collapsed state. This is useful for navigating deeply nested JSON without manually searching through text. The Expand all and Collapse all controls apply to the full tree; Expand all is limited to documents with at most 1,000 values so a very large payload does not flood the page with rendered nodes.
JSON5 and JSONC
Standard JSON has strict rules: no comments, no trailing commas, no single-quoted strings, no unquoted keys. Two popular supersets relax these rules:
- JSON5: supports comments, trailing commas, single-quoted strings, unquoted keys, and hex literals. Used in some configuration tools.
- JSONC (JSON with Comments): JSON plus C-style
//and/* */comments. Used by VS Code, TypeScript (tsconfig.json), and other tooling.
Strict JSON is the default. Turn on Allow JSONC comments and trailing commas to format JSONC configuration files without editing out comments first. The option removes comments and trailing commas while preserving line breaks for useful parser error locations. It does not enable the broader JSON5 syntax, so single-quoted strings, unquoted keys, and hexadecimal numbers still need conversion.
Large JSON performance
This tool handles most JSON files well. For very large files (>5 MB), browser-based tools become slow due to rendering limits. For large JSON, consider command-line tools:
-
jq . input.json- format and query JSON with the ubiquitousjqtool python3 -m json.tool input.json- format using Python's standard librarycat input.json | fx- interactive JSON explorer in the terminal
Local files and privacy
Use Open file or drop a .json file into the input area to read it
on this device. The filename and file size are shown above the result, and Download saves the current
formatted output as a new .json file. File reading, parsing, sorting, formatting, and
saving all happen in the browser; the tool does not upload your JSON. The input and formatted size
summary reports character counts and UTF-8 byte sizes, which helps compare the effect of minification
on a payload.
Frequently asked questions
Is my JSON data sent to a server?
No. Pasted text and files you open are read and processed in your browser with the built-in JavaScript `JSON.parse` and `JSON.stringify` APIs. Nothing is uploaded.
Why does the formatter show a line and column number for errors?
When the browser's JSON parser throws a `SyntaxError`, the tool extracts the character position from the error message and maps it back to a line and column number. This makes it much faster to locate the typo or missing bracket in large JSON.
What does "Sort keys" do?
Sorting keys reorders every object's keys alphabetically at every level of nesting. This makes it easy to compare two JSON objects visually or produce deterministic output for diffing.
What is the minified output useful for?
Minified JSON removes all whitespace, producing the smallest possible string. This is useful when sending JSON in HTTP requests, storing it in a database, or embedding it in code where file size matters.
What do the JSON stats mean?
Object count is the number of `{}` nodes. Array count is the number of `[]` nodes. Key count is the total number of object keys across all objects. Max depth is how many levels of nesting the deepest value sits at. Input and formatted sizes show character counts and UTF-8 byte sizes.
Can I format JSONC files?
Strict JSON is the default. Turn on JSONC mode to accept // or /* */ comments and trailing commas. JSONC mode does not accept other JSON5 syntax such as unquoted keys or single-quoted strings.
Related tools
- CSV to JSONConvert a CSV file or pasted table into JSON records for APIs, fixtures, or config data.
- JSON to CSVTurn JSON arrays of objects into a CSV file for spreadsheets and data review.
- JSON Path TesterTest JSONPath expressions to select nested values from a JSON document.
- JSON ↔ YAMLConvert JSON to YAML or YAML to JSON when moving between application configs.
- JSON Diff ViewerCompare two JSON documents side by side to find added, removed, or changed values.
- JSON Schema ValidatorCheck a JSON document against a JSON Schema to verify its structure and required fields.