# How to Validate JSON

> Check if your JSON is valid and get precise error messages with line numbers for any syntax issues.

- URL: https://www.browserutils.dev/how-to/validate-json
- Published: 2026-03-05
- Updated: 2026-03-16

---

## Step 1: Paste your JSON

Paste the JSON you want to validate into the input editor.

## Step 2: Check the result

The validator instantly checks your JSON syntax. Valid JSON gets a green confirmation. Invalid JSON shows the exact error with line and column numbers.

## Step 3: Fix errors

Use the error details to locate and fix syntax issues — missing commas, unclosed brackets, trailing commas, or invalid values.

## Step 4: Format if needed

Once valid, you can format the JSON for readability or switch to the JSON Formatter tool.

JSON syntax is strict — a single misplaced comma or missing quote will cause your parser to reject the entire document. When you are staring at a 500-line config file and the error message just says "Unexpected token," the [JSON Validator](/tools/json-validator) pinpoints exactly where the problem is.

## Understanding JSON validation

JSON validation checks whether a string conforms to the JSON specification defined in RFC 8259. Unlike more forgiving formats, JSON has no optional syntax or alternative styles. Every rule is mandatory: double quotes for strings, no trailing commas, no comments, no single quotes, no undefined values.

This strictness is by design. JSON was created to be a minimal, unambiguous data interchange format that any parser in any language can handle identically. But it also means that formats that look like JSON — JavaScript object literals, Python dictionaries, JSON5, JSONC — will fail strict validation even though they are "close."

If you are working with a format that allows comments or trailing commas (like `tsconfig.json` or VS Code settings), you are actually working with JSONC or JSON5, not standard JSON. These are supersets that need their own parsers. A standard JSON validator will rightfully reject them.

## Tips and best practices

- **Validate before deploying.** A broken JSON config file can bring down an application at startup. Run validation as part of your CI pipeline, especially for i18n files, feature flags, and environment configs.
- **Use the error line number.** When the validator reports an error at line 47, the actual mistake is often on line 46 — a missing comma at the end of the previous line is the most frequent culprit.
- **Validate API responses during development.** If your API returns invalid JSON, clients will crash. Add validation to your integration tests to catch serialization bugs early.
- **Be careful with numbers.** JSON supports numbers but has no distinction between integers and floats. Extremely large integers (beyond 2^53) lose precision in JavaScript parsers. If you need exact large numbers, send them as strings.
- **Check encoding.** JSON must be UTF-8 encoded. If your file contains characters from a different encoding (like Latin-1), the parser may choke on byte sequences that are not valid UTF-8.

## Troubleshooting

- **"Unexpected token at position 0":** This usually means the input is not JSON at all — it might be HTML (from a 404 page), XML, or plain text. Check what your API is actually returning.
- **"Unexpected end of input":** You have an unclosed bracket, brace, or string somewhere. The parser reached the end of the document while still expecting a closing delimiter. Use the [JSON Formatter](/tools/json-formatter) to help locate the mismatch.
- **Valid JSON but wrong structure:** Validation only checks syntax, not semantics. `{"name": 42}` is valid JSON even if your application expects `name` to be a string. For structural validation, you need JSON Schema.