ToolNimbus

JSON Validator

When an API call fails or a config file refuses to load, the cause is almost always a tiny syntax slip somewhere in the JSON. This free JSON Validator helps you find the error in JSON instantly: paste your data, click Validate, and get the exact parser error message and position when something is wrong. For valid JSON it confirms success and reports the root data type, the minified size in bytes, and the maximum nesting depth. Everything runs locally in your browser, so even large or sensitive payloads never leave your machine.

Paste your JSON to validate

How to Use

Paste or type your JSON into the large text area at the top of the page, then click the Validate JSON button. If the JSON is syntactically valid, you will see a green "Valid JSON" message along with three stats: the root Type (Object, Array, or a primitive such as string, number, or boolean), the size in Bytes (minified), and the Max Depth of nesting. If the JSON is invalid, you get a red message showing the exact error reported by the browser's built-in JSON parser, which typically names the unexpected character or token and the position in the string where parsing failed. Use that position to jump straight to the problem, fix it, and click Validate again until you get the green result. If the box is empty, the tool simply tells you the input is empty. There are no settings to configure and nothing to upload.

Why This Tool Is Useful

A single missing comma, stray quote, or unclosed bracket can break an entire JSON payload and trigger confusing errors deep inside your application or API. This validator catches those syntax problems in one click and tells you where they are, so you spend seconds fixing rather than minutes guessing. The extra stats are handy too: the type and depth help you sanity-check that the data is shaped the way you expect, and the minified size in bytes is useful when you are watching request limits or storage. Because validation happens entirely in your browser using the native JSON parser, you can safely check API responses, tokens, and other private data without sending anything to a server.

How to check if your JSON is valid

Checking whether JSON is valid means confirming it follows the JSON syntax rules: the right brackets and braces, double-quoted strings and keys, commas only between items, and no leftover characters. The fastest way is to let a parser do the work. This tool runs your input through the browser's built-in JSON parser, the same one Node.js uses, so if it passes here, it will parse in real code too.

Paste your data, click Validate JSON, and read the result. A green message means the structure is sound. A red message means the parser stopped at a character it did not expect, and the message names that character and its position so you can find the error in JSON without hunting line by line.

Common JSON errors and how to fix them

Most invalid JSON comes from a short list of recurring mistakes. Knowing these common JSON errors by sight makes debugging far quicker, because the parser error usually points at the symptom rather than the root cause. The reference table below maps each common error to what causes it and how to fix it.

The errors you will hit most often are trailing commas, single quotes used instead of double quotes, unescaped quotes or newlines inside strings, and forgetting to close a brace or bracket. Each one produces an 'unexpected token' or 'unexpected end of input' style message from the parser.

  • Trailing comma: a comma after the last item in an object or array is not allowed in JSON.
  • Single quotes: JSON requires double quotes for both strings and keys.
  • Unquoted keys: every property name must be wrapped in double quotes.
  • Unescaped characters: literal newlines and unescaped double quotes inside a string break parsing.
  • Unbalanced brackets: every { needs a } and every [ needs a ].

How JSON differs from JavaScript object literals

JSON looks like a JavaScript object, but it is a stricter data format, and assuming the two are identical is the cause of many errors. JavaScript is forgiving; JSON is not. Code that is perfectly valid as a JavaScript literal will often fail when you try to parse it as JSON.

The key differences are easy to remember once you have been burned by them. JSON allows double quotes only, forbids trailing commas, has no comments at all, and requires every key to be quoted. JavaScript permits single quotes, unquoted identifiers as keys, trailing commas, and // or /* */ comments.

  • Double quotes only: "name" is valid; 'name' is not.
  • No trailing commas: remove the comma after the last element.
  • No comments: strip // and /* */ before parsing.
  • Quoted keys: {name: 1} is invalid JSON; {"name": 1} is correct.
  • No undefined, functions, NaN, or Infinity values.

Reading the parser error message and position

When validation fails, the message you see comes directly from the browser's JSON parser. Depending on your browser it may read like 'Unexpected token } in JSON at position 42' or 'Expected double-quoted property name'. The position number counts characters from the start of your input, which lets you locate the problem precisely.

Remember that the parser reports where it noticed something was wrong, not always where you made the mistake. A missing comma, for example, is often flagged at the start of the next item. When the message says 'Unexpected end of input', you are usually missing a closing brace or bracket at the very end.

What the validator reports for valid JSON

A green result confirms your JSON is syntactically correct and shows three useful facts about it. Type is the root value: Object for {...}, Array for [...], or a primitive type such as string, number, or boolean if the entire document is a single value. Bytes (minified) is the size after whitespace is removed, which is the smallest the payload can be. Max Depth is how many levels of nested objects and arrays the data contains, so a single object with no nesting reports a depth of one.

These numbers help you confirm the shape of your data at a glance. A surprising depth or type often reveals that the JSON is not structured the way you expected, even though it parses cleanly.

Syntactic validation versus JSON Schema validation

This tool checks that your JSON is syntactically valid, meaning it parses without error. It does not perform JSON Schema validation, so it will not confirm that a given field exists, has the right type, or matches a required pattern.

In other words, {"age": "hello"} is perfectly valid JSON even if your application expects age to be a number. Use this validator to rule out syntax problems first; if the data parses but your program still rejects it, the issue is with the data's structure or values against your own rules, not its JSON syntax.

Common JSON errors: cause and fix

ErrorCauseFix
Trailing commaA comma placed after the last item in an object or array, which JSON does not permitDelete the comma before the closing } or ]
Single quotes instead of double quotesStrings or keys wrapped in 'single quotes', which are not allowed in JSONReplace every single quote with a double quote
Unescaped quote or newline inside a stringA literal double quote or line break sits inside a string value without escapingEscape them as \" and \n, or use the proper escape sequence
Missing closing brace or bracketAn opening { or [ is never closed, giving an 'unexpected end of input' errorAdd the matching } or ] so every opener is balanced
Property name not in double quotesA key written bare like name: instead of "name":Wrap every property name in double quotes
Comments are not allowed// or /* */ comments copied from JavaScript or config filesRemove all comments before parsing the JSON
Duplicate keysThe same key appears twice in one objectRename or remove the duplicate; parsers keep only the last value

Frequently Asked Questions

How do I know if my JSON is valid?

Paste it into the validator and click Validate JSON. A green 'Valid JSON' message means it parses correctly; a red message means there is a syntax error. The tool uses the browser's built-in parser, the same one Node.js uses, so a green result means your JSON will parse in real code too.

Why is my JSON invalid?

Almost always because of a small syntax slip: a trailing comma, single quotes instead of double quotes, an unquoted key, an unescaped character inside a string, or a missing closing brace or bracket. The red error message names the unexpected token and its position so you can jump to the spot and fix it.

What are the most common JSON errors and how do I fix them?

Trailing commas, single quotes used in place of double quotes, property names that are not quoted, unescaped quotes or newlines inside strings, and unbalanced braces or brackets. The reference table on this page lists each common JSON error with its cause and how to fix it.

Does JSON allow trailing commas or comments?

No to both. A comma after the last item in an object or array is invalid JSON, and JSON has no comment syntax at all. Remove any // or /* */ comments and any trailing commas before validating, even though both are legal in JavaScript.

Can JSON use single quotes?

No. JSON requires double quotes for every string value and every key. A value like 'hello' or a key like 'name' will fail to parse. Replace all single quotes with double quotes to fix it.

What is the difference between validating and formatting JSON?

Validating checks whether the JSON is syntactically correct and reports errors, which is what this tool does. Formatting re-indents valid JSON to make it readable. If you want to pretty-print or minify your data after it passes validation, use our JSON Formatter.

Does the tool tell me where the error is?

Yes. When JSON is invalid, the message shown is the parser's own error, which typically includes the unexpected character and a position number counting from the start of your input. Note that the parser flags where it noticed the problem, which can be just after the real mistake, such as a missing comma.

What details does it show for valid JSON?

It shows the root data Type (Object, Array, or a primitive such as string, number, or boolean), the size in Bytes (minified), and the Max Depth of nesting. These help you confirm the data is shaped the way you expect at a glance.

Does this perform JSON Schema validation?

No. It only checks that the JSON is syntactically valid, meaning it parses without error. It does not verify that specific fields exist, have the right types, or match a schema. Data like {"age": "hello"} is valid JSON even if your app expects a number.

Is my data private, and can I validate large files?

Yes to both. All validation runs entirely in your browser, so nothing is sent to a server, and you can safely check API tokens or other sensitive data. The same local processing handles large JSON payloads. If you also need to encode or decode data, try our Base64 Encoder / Decoder.

Related Tools