How to Format and Validate JSON Online

To format and validate JSON online, paste it into the Toolstik JSON Formatter & Validator and click Format. If the JSON is valid, you get indented output and a Valid JSON badge. If it isn't, you get an Invalid JSON message, with a line and column when your browser reports one. Everything runs in your browser, so you can safely paste API responses and config files.
Try it now
JSON Formatter & Validator
Loading tool…
Step by step: format JSON
- Open the JSON Formatter. The JSON input box starts with a small sample. Replace it with your own JSON.
- Pick an indent from the menu on the right: 2 spaces (default), 4 spaces, or 8 spaces.
- Click Format. The tool parses your input, then prints it with the indent you picked.
- Check the result panel. A Valid JSON badge appears next to a count such as "12 keys (nested count)". That number counts every object key at every depth, which helps you spot a response that came back much smaller than expected.
- Click Copy to put the output on your clipboard, or Download to save it as
formatted.json. Reset brings back the sample and clears the result.
Here is what Format does with a compact API response:
{"a":[1,2],"b":{"c":true}}
becomes (with 2 spaces):
{
"a": [
1,
2
],
"b": {
"c": true
}
}
Step by step: minify JSON
Click Minify instead of Format. You get the same data on one line with all optional whitespace removed. Use it when you're pasting JSON into an environment variable, a curl body, or a test fixture. For when each one makes sense, see JSON pretty print vs minify.
Step by step: validate JSON
Click Validate when you just need a yes or no. All three buttons parse your input first, so any of them will catch a syntax error. Validate is the quick check, and on success it shows the indented output too.
When parsing fails, the red Invalid JSON box shows your browser's parser message. If that message includes a character position, Toolstik turns it into a line and column, for example (line 1, column 8). Some errors, depending on the browser and the error type, come with no position. In that case you see the message alone.
The exact wording comes from the browser's JavaScript engine, so Chrome, Firefox, and Safari describe the same mistake differently. Don't rely on the exact text. Go to the reported line and look at the character just before the column, which is usually where the real problem is.
What happens to your JSON
The tool trims leading and trailing whitespace, runs JSON.parse, then serializes the result with JSON.stringify. That round trip has a few side effects worth knowing:
- Duplicate keys collapse.
{"a":1,"a":2}comes out as{"a":2}. The last value wins, with no warning. - Integer-like keys move first. JavaScript orders keys like
"2"before string keys, so{"b":1,"2":0}comes out as{"2":0,"b":1}. - Very large numbers lose precision. Numbers become 64-bit floats, so
12345678901234567890is printed as12345678901234567000. If your IDs are that big, send them as strings. - A leading byte-order mark (BOM) is stripped by the trim step, so a BOM-prefixed file that a strict parser rejects will still validate here. Remove the BOM in the source file too.
None of this changes valid JSON in a way most apps care about. Keep it in mind before you paste formatted output back over a source file that has duplicate keys or 19-digit IDs.
Doing the same thing from the command line
If the JSON lives in a file and you have a terminal handy, these produce the same results:
# Pretty print
jq . data.json
python3 -m json.tool data.json
python3 -m json.tool --indent 4 data.json
# Minify
jq -c . data.json
python3 -m json.tool --compact data.json
In JavaScript, it's the same two calls the tool uses:
const data = JSON.parse(text); // throws SyntaxError on invalid JSON
const pretty = JSON.stringify(data, null, 2);
const minified = JSON.stringify(data);
Troubleshooting
- "Expected double-quoted property name" or similar near a closing brace. Almost always a trailing comma. Remove the comma after the last item.
- Error at column 2 of line 1. Look for single quotes or unquoted keys, which are common when you copy a JavaScript object literal.
- Error inside a string. A raw line break or tab inside a string value isn't allowed. Use
\nor\t. - Valid here, rejected elsewhere. Check for a BOM or invisible characters at the start of the file.
Common JSON errors and how to fix them walks through each of these with before and after examples.
Limits
- Syntax only, with no JSON Schema validation and no tree view.
- Very large payloads (many megabytes) can make the browser tab slow, because the whole document is parsed and rendered at once.
- JSON5 and JSONC (comments, trailing commas) are rejected, because the tool uses the strict JSON parser.
Related developer tools
JSON often arrives inside other formats. A JWT payload is Base64URL-encoded JSON, so you can read it with the JWT Decoder. If you're writing structured data for search engines, the Schema Markup Generator outputs JSON-LD you can check here. For the full set of free utilities, see free developer tools online.
Frequently asked questions
Tools in this guide
JSON Formatter & Validator
Format, validate, and minify JSON. Tree view with syntax error highlighting.
JWT Decoder
Decode JWT header and payload locally. Inspect claims—signature is not verified.
Schema Markup Generator
Generate JSON-LD structured data for FAQ, Article, Organization, and Product pages.
Keep reading
- DeveloperCommon JSON Errors and How to Fix ThemFix common JSON errors fast: trailing commas, single quotes, unquoted keys, comments, BOMs, NaN, and raw line breaks, with before-and-after examples.
- DeveloperJSON Pretty Print vs Minify — What's the Difference?JSON pretty print vs minify: what each does, how much size you actually save, how gzip changes the math, and when to use each format in your workflow.
- DeveloperFree Developer Tools Online: JSON, JWT, Base64, URL, Timestamp & RegexFree developer tools online that run in your browser: format JSON, decode JWTs, encode Base64 and URLs, convert Unix timestamps, and test JavaScript regex.