logo
logo

Free JSON Validator Online - Check Syntax & Format JSON | Lembog

JSON Validator

Validate, format, and analyze JSON data with detailed error messages

Indent:
0 characters
Enter JSON to validate

Common JSON Errors

• Trailing commas after last item
• Single quotes instead of double quotes
• Missing quotes around keys
• Unescaped special characters
• Comments (not allowed in JSON)
• Undefined values

Free JSON Validator Online - Check JSON Syntax Instantly

Validate, format, and analyze JSON data with detailed error messages. Find and fix syntax errors in seconds, minify for production, or beautify for readability.

Features at a Glance

  • Real-time validation — Instant syntax checking
  • Error location — Line and column numbers
  • Auto-formatting — Beautify with 2 or 4 space indentation
  • Minification — Compress for production
  • JSON statistics — Objects, arrays, depth analysis
  • One-click copy — Formatted or minified
  • Download — Save as .json file

How to Use the JSON Validator

  1. Paste your JSON in the input area
  2. See instant validation — Green checkmark for valid, red error for invalid
  3. View error details — Line number and error description
  4. Format or minify — Use toolbar buttons
  5. Copy or download — One-click actions

Understanding JSON Errors

Syntax Errors

ErrorProblemSolution
Unexpected tokenInvalid characterCheck for typos
Unexpected endIncomplete JSONClose all brackets
Expected colonMissing key separatorAdd : after key
Expected commaMissing item separatorAdd , between items

Common Mistakes

1. Trailing Commas

// ❌ Invalid
{ "name": "John", }

// ✅ Valid
{ "name": "John" }

2. Single Quotes

// ❌ Invalid
{ 'name': 'John' }

// ✅ Valid
{ "name": "John" }

3. Unquoted Keys

// ❌ Invalid
{ name: "John" }

// ✅ Valid
{ "name": "John" }

4. Comments

// ❌ Invalid (no comments in JSON)
{
  // user name
  "name": "John"
}

// ✅ Valid
{ "name": "John" }

5. Single vs Double Quotes in Strings

// ❌ Invalid
{ "quote": "He said 'hello'" }  // This is actually valid!

// ❌ Invalid
{ "quote": "He said "hello"" }  // Unescaped quotes

// ✅ Valid
{ "quote": "He said \"hello\"" }

JSON vs JavaScript Objects

JSON is not the same as JavaScript objects:

FeatureJSONJavaScript Object
KeysMust be double-quotedCan be unquoted
StringsDouble quotes onlySingle or double
Trailing commasNot allowedAllowed
CommentsNot allowedAllowed
FunctionsNot allowedAllowed
undefinedNot allowedAllowed

JSON Data Types

JSON supports these data types:

  • String"hello" (double quotes only)
  • Number42, 3.14, -17, 1e10
  • Booleantrue, false
  • Nullnull
  • Array[1, 2, 3]
  • Object{"key": "value"}

When to Validate JSON

  • API development — Ensure request/response validity
  • Configuration files — Validate config.json, package.json
  • Data import/export — Verify data integrity
  • Debugging — Find why JSON parse fails
  • Code review — Check JSON in PRs

JSON Best Practices

1. Use Consistent Formatting

  • Choose 2 or 4 space indentation
  • Be consistent throughout your project

2. Validate Before Deploy

  • Always validate production JSON
  • Use schema validation for complex data

3. Handle Errors Gracefully

try {
  const data = JSON.parse(jsonString);
} catch (e) {
  console.error('Invalid JSON:', e.message);
}

4. Use TypeScript Types

interface User {
  name: string;
  age: number;
}
const user: User = JSON.parse(jsonString);

JSON Schema Validation

For advanced validation, consider JSON Schema:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer", "minimum": 0 }
  },
  "required": ["name"]
}

FAQs About JSON Validation

What makes JSON invalid?

Missing quotes, trailing commas, single quotes, comments, or unrecognized escape sequences.

Can JSON have comments?

No, standard JSON does not support comments. Use JSONC or JSON5 for comment support.

How do I fix "Unexpected token"?

Look at the position indicated and check for typos, missing quotes, or invalid characters.

Is whitespace significant in JSON?

No, whitespace is ignored. You can format with any indentation.

Can JSON keys be numbers?

Yes, but they must still be quoted: {"123": "value"}

What's the maximum JSON size?

There's no limit in the JSON spec, but parsers may have memory limits.

Why Use Our JSON Validator?

  • Real-time validation — No submit button needed
  • Detailed errors — Line and column numbers
  • JSON statistics — Analyze structure and depth
  • Format options — 2 or 4 space indentation
  • Minify feature — Compress for production
  • Download option — Save validated JSON
  • Privacy focused — All processing is client-side
  • 100% free — No limits, no signup