Xerobit

JSON Validator: Check Syntax and Find Errors Instantly

Paste your text into this json validator to check if it is syntactically correct and find exactly where any errors occur. It works like a lightweight jsonlint, reporting the error message, line number, and column alongside basic statistics about your data. Everything runs locally in your browser, so nothing is uploaded to a server.

Paste the text you want to validate json syntax for.

Result

  • Status
    Valid JSON
  • Root type
    Object
  • Depth
    2
  • Total keys
    2
  • Size
    40 B
  • Lines
    1

How to use the json validator

  1. Paste or type your text into the JSON input field.
  2. The json validator checks the syntax automatically as you type.
  3. If valid, review the statistics including depth, keys, and size.
  4. If invalid, read the error message and note the exact line and column.
  5. Fix the issue in your source file and paste the corrected text back.

What makes JSON valid

The JSON specification (RFC 8259) defines a strict grammar. To validate json successfully, your text must follow these rules:

  • Data is enclosed in curly braces {} for objects or square brackets [] for arrays.
  • Object keys must be double-quoted strings. Single quotes are not allowed.
  • Strings must use double quotes. Unquoted words are only valid for true, false, and null.
  • Numbers cannot have leading zeros (except 0 itself) and cannot be NaN or Infinity.
  • No trailing commas are permitted after the last item in an array or object.
  • No comments of any kind (// or /* */) are allowed.

A common mistake when using a json validator is pasting JavaScript object notation instead of strict JSON. For example, {key: 'value'} is valid JavaScript but fails JSON validation because the key lacks double quotes and the string uses single quotes.

Understanding error messages

When you validate json that contains a syntax error, the parser stops at the first character it cannot process. The error message typically includes a description and a position. This tool converts that position into a human-readable line and column number.

Consider this broken input:

{"name": "test",}

The parser encounters the closing brace immediately after a comma, which violates the grammar. The reported position points directly to the }. Removing the trailing comma fixes the issue. Another frequent error is forgetting to escape internal quotes within a string, such as {"msg": "He said "hi""}, which should be written as {"msg": "He said \"hi\""}.

If you need to convert validated data into another format, tools like json to csv can help once your syntax is confirmed correct.

JSON Validator vs JSONLint

JSONLint was one of the first popular web-based tools to validate json, and its name became synonymous with the task. However, sending data to a remote server for linting raises privacy concerns when working with sensitive configuration files, API responses, or proprietary data structures.

This json validator performs the same syntax checking entirely in your browser. No network requests are made. It uses the native JSON.parse() method available in all modern browsers and Node.js environments, ensuring standard-compliant validation without external dependencies.

While dedicated linters might offer stylistic opinions (like enforcing two-space indentation), a validator focuses strictly on structural correctness. If you need to reformat valid data, use a json formatter after confirming it passes validation.

Common JSON mistakes reference

The table below lists frequent errors encountered when developers try to validate json, along with their corrections.

MistakeInvalid ExampleCorrected
Single quotes{'a': 1}{"a": 1}
Unquoted keys{a: 1}{"a": 1}
Trailing comma[1, 2,][1, 2]
Comments{"a": 1 // note}{"a": 1}
Undefined value{"a": undefined}{"a": null}
Leading zero{"n": 07}{"n": 7}
Hexadecimal{"n": 0xFF}{"n": 255}

Keeping this list handy speeds up debugging when your json validator reports an unexpected token.

Working with parsed data

Once you validate json successfully, you often need to manipulate it programmatically. In JavaScript, JSON.parse() converts the text into an object, while JSON.stringify() does the reverse. If you are building workflows that require serializing objects back to text safely, the json stringify tool handles escaping and formatting options.

For comparing two validated payloads to spot differences in structure or values, a json diff utility highlights exactly what changed between versions. Validating first ensures that comparison tools do not fail on syntax errors before they even begin analyzing content.

Worked examples

Each result below was produced by the same code the tool runs, so you can check your own numbers against them.

ExampleInputResult
Valid objectJSON input: {"name":"Ada","year":1815,"pioneer":true}Status: Valid JSON; Root type: Object; Depth: 1; Total keys: 3; Size: 41 B; Lines: 1
Trailing comma errorJSON input: [1, 2, 3,]Status: Invalid; Message: Unexpected token ']', "[1, 2, 3,]" is not valid JSON
Missing quotes on keyJSON input: {key: "value"}Status: Invalid; Error location: Line 1, Column 2; Message: Expected property name or '}' in JSON at position 1 (line 1 column 2)
Nested structureJSON input: {"users":[{"id":1,"active":true},{"id":2,"active":false}]}Status: Valid JSON; Root type: Object; Depth: 3; Total keys: 5; Size: 58 B; Lines: 1

FAQ

Is this json validator safe for sensitive data?

Yes. All processing happens locally in your browser using native JavaScript functions. Your text is never sent to any server, making it safe for API keys, tokens, and private configurations.

Why does my JSON fail validation if it works in JavaScript?

JavaScript objects allow single quotes, unquoted keys, trailing commas, and comments. Strict JSON does not permit any of these. You must conform to RFC 8259 to validate json successfully.

Can I validate multiple JSON objects at once?

A valid JSON text must contain exactly one top-level value. If you have multiple objects, wrap them in an array like [{}, {}] or combine them into a single parent object.

How is this different from jsonlint?

JSONLint traditionally sends data to a remote server for processing. This tool acts as a local jsonlint alternative, providing identical syntax checking without network transmission.

Does this tool format or minify my JSON?

No. This json validator only checks syntax and reports statistics. Use a dedicated formatter or minifier if you need to change whitespace or indentation.

What does the depth statistic mean?

Depth indicates how many levels of nested objects or arrays exist. A flat object like {"a": 1} has depth 1, while {"a": {"b": 1}} has depth 2.