How to format and validate JSON
- Paste your JSON into the input box; it's validated as you type.
- Choose 2 spaces, 4 spaces or tabs, and tick Sort keys A→Z if you want ordered keys.
- Click Format to beautify, or Minify to compress it into one line.
- Switch to Tree view to browse nested data, then Copy or Download the result.
What you can do with JSON Formatter & Validator
- Precise error messages
- Invalid JSON shows the problem, line and column with a caret under the exact character, such as a trailing comma or single quotes.
- Format or minify
- Beautify with 2 spaces, 4 spaces or tabs, or minify to a single line to cut payload size.
- Collapsible tree view
- Explore objects and arrays as an expandable tree with item counts and color-coded strings, numbers, booleans and nulls.
- Sort keys
- Order object keys alphabetically at every level, which makes two JSON files much easier to compare.
- Size stats
- See whether the input is an object or array, how many keys or items it has, and its byte size before and after.
- Download and reuse
- Copy the output, download it as data.json or data.min.json, or send it back to the input for further edits.
Common JSON errors and when to format or minify
JSON (JavaScript Object Notation) is the standard format for APIs, configuration files and data exchange, defined in RFC 8259. It's stricter than JavaScript object syntax, which is why so many hand-edited files break. The most common errors are trailing commas after the last item, single quotes instead of double quotes, unquoted property names, comments, and raw line breaks inside strings. This validator names these mistakes specifically instead of showing a generic parse error, and points to the line and column where parsing failed.
Pretty-printed JSON is for humans; minified JSON is for machines. Indentation makes nested structures readable when you debug an API response or review a config file, while minifying removes all unnecessary whitespace to shrink payloads and storage. Sorting keys produces a canonical order, useful before diffing two files or committing config to version control. JSON numbers are parsed as JavaScript numbers, so integers above 2^53, such as some 64-bit IDs, can lose precision when reformatted.
Frequently asked questions
Is it safe to paste API responses or config files here?
Yes. The JSON is parsed and formatted by your browser's built-in JSON engine and never leaves your device. Nothing is uploaded or logged, so you can work with API keys, customer records or internal configuration without exposing them.
Why is my JSON invalid?
The most common causes are a trailing comma before } or ], single-quoted strings, property names without double quotes, comments, and unescaped line breaks inside strings. The error message tells you which one it is and shows the line and column, with a caret under the problem.
Can it handle large JSON files?
Yes. Files of several megabytes format quickly. For very large outputs the text preview is truncated at 2 million characters, but Copy and Download still give you the full result. The tree view loads nested levels only when you expand them, so it stays responsive.
Does it support JSON with comments (JSONC) or JSON5?
No. It validates strict JSON as defined by RFC 8259, so comments, trailing commas and single quotes are reported as errors. Remove them first, or use the error messages to find and fix each one in turn.
Does it change my numbers or key order?
Key order is preserved unless you tick Sort keys. Numbers are re-serialized, so 1.0 becomes 1 and 1e3 becomes 1000, and very large integers beyond 2^53 can lose precision because JavaScript stores numbers as 64-bit floats.