JSON Formatter & Validator
Beautify or minify JSON, sort keys, and validate it with the exact line and column of any syntax error. Everything runs locally in your browser.
- Exact error line and column
- Beautify, minify and sort keys
- Big numbers kept intact
Input
Paste your JSON
Formatted JSON
Paste JSON on the left to validate and format it.
- Keys
- –
- Depth
- –
- Input size
- –
- Output size
- –
How to use
How to Format and Validate JSON
- 1
Paste your JSON
Paste or type JSON into the input box, or load the sample to try it out.
- 2
Pick the output
Choose Beautify with 2 spaces, 4 spaces or tabs, or Minify for the smallest output. Turn on Sort keys if you want properties in alphabetical order.
- 3
Fix any errors
If the JSON is invalid, read the line and column in the error box and look for the caret under the problem character.
- 4
Copy or download
Copy the result to your clipboard or download it as a .json file.
Common JSON Syntax Errors
These are the mistakes the validator flags most often. Each one is valid in JavaScript or JSON5 but not in standard JSON.
{"a": 1,}Trailing comma after the last property or array item.
{'a': 1}Single quotes. JSON strings and keys must use double quotes.
{a: 1}Unquoted property name.
{"a": 01}Leading zero on a number.
{"ok": True}Capitalised literal. Use lowercase true, false and null.
{"a": 1} // noteComments are not part of JSON.
Beautify vs Minify: Worked Example
The same data, minified (one line, no spaces) and beautified with 2-space indentation:
Minified, 35 bytes
{"id":7,"tags":["a","b"],"ok":true}Beautified, 2 spaces
{
"id": 7,
"tags": [
"a",
"b"
],
"ok": true
}This document has 3 keys and a depth of 2 (the object, plus the array inside it). Minified JSON is best for sending over the network; beautified JSON is easier to read, review and diff.
Common Use Cases
Debugging API responses
Paste a raw response body to read it with indentation and spot missing fields.
Checking config files
Validate package.json, tsconfig-style or app config files before you commit them.
Shrinking payloads
Minify JSON fixtures or embedded data to remove unnecessary whitespace.
Cleaner diffs
Sort keys so two JSON files with the same data line up when you compare them.
FAQ
Frequently Asked Questions
How do I format JSON online?
Paste your JSON into the input box. If it is valid, the formatted version appears on the right with 2-space, 4-space or tab indentation. Switch to Minify to remove all whitespace instead, then copy or download the result.
How does the JSON validator find errors?
The tool parses your text with a strict JSON parser that follows RFC 8259. When it hits something that is not allowed, such as a trailing comma, single quotes, a comment or a missing bracket, it stops and shows the error message with the exact line and column plus a caret under the problem character.
Will formatting change my numbers or key order?
No. Numbers are written back exactly as you typed them, so very large integers like 12345678901234567890 keep every digit, and keys stay in their original order unless you turn on Sort keys. String escape sequences are also kept as written.
Is my JSON sent to a server?
No. Parsing, formatting and validation all run in JavaScript inside your browser. Nothing you paste is uploaded or stored.
What do the keys and depth stats mean?
Keys is the total number of object properties across the whole document. Depth is the deepest level of nesting: a plain value has depth 0, an empty object or array has depth 1, and {"a": [1]} has depth 2. Input and output size are shown in UTF-8 bytes.
Does it accept JSON5, comments or trailing commas?
No. The validator checks standard JSON only, so comments, trailing commas, single-quoted strings, unquoted keys, NaN and undefined are reported as errors. This matches what JSON.parse and most APIs accept.
Keep going
Related Tools
Hand-picked tools that pair well with this one. All free, no sign-up.
- Developers
JWT Decoder
Decode JSON Web Token headers and payloads instantly, with readable expiry times and token status, right in your browser.
- Header & payload
- Expiry status
- Runs locally
Open tool - Everyday
CSV Viewer & Editor
View, edit, and analyze CSV, TSV, and JSON files with search, filter, sort, and export.
- Multiple formats
- Search & filter
- Edit cells
Open tool - Developers
Base64 Encoder / Decoder
Convert text, files, and images to and from Base64 with live previews and MIME detection.
- Text and file modes
- Image preview
- URL-safe option
Open tool