JSON5 Validator

Validate JSON5 syntax and check for common errors

What is JSON5 Validator?

JSON5 is a superset of JSON that makes it easier to write and maintain configuration files by hand. It adds features like unquoted keys, single-quoted strings, trailing commas, comments, and hexadecimal numbers. This validator checks your JSON5 content for syntax errors and identifies which JSON5 features you're using.

How to Use

  1. Paste your JSON5 content in the text area
  2. Click Validate to check for syntax errors
  3. If valid, the tool shows which JSON5 features are used
  4. If invalid, the error message includes the approximate location
  5. Fix any errors and re-validate

Why Use This Tool?

Catch JSON5 syntax errors before deploying config files
Verify that your JSON5 is well-formed
Identify which JSON5 features your file uses
Validate configuration files for tools that use JSON5 (Babel, ESLint, tsconfig, etc.)

Tips & Best Practices

  • JSON5 files commonly use .json5 extension or are used in config files like .babelrc, tsconfig.json
  • Standard JSON is always valid JSON5 — if your file is valid JSON, it's valid JSON5 too
  • Not all parsers support JSON5 — check that your target environment supports it
  • Use JSON5 for human-written config files, standard JSON for API communication

Frequently Asked Questions

What is the difference between JSON and JSON5?

JSON5 extends JSON with features that make it easier to write by hand: unquoted keys, single-quoted strings, trailing commas, comments (// and /* */), hexadecimal numbers, and multi-line strings. Standard JSON requires double-quoted keys and strings, no trailing commas, and no comments.

Which tools use JSON5?

Popular tools that use JSON5 syntax include Babel (.babelrc), TypeScript (tsconfig.json with comments), ESLint (.eslintrc), Prettier (.prettierrc), and Renovate. Many Node.js config files accept JSON5 format.

Can I use JSON5 in the browser?

Not natively. Browsers only support JSON.parse() for standard JSON. To use JSON5 in the browser, you need the json5 npm package. For config files read by build tools, JSON5 works because the tools parse it server-side.

How does this validator work?

The validator first tries standard JSON.parse(). If that fails, it cleans JSON5-specific syntax (removes comments, quotes unquoted keys, removes trailing commas, converts single quotes) and tries again. This approach catches most errors but may not be 100% accurate for all edge cases.

Is JSON5 slower than JSON?

JSON5 parsing is slower than JSON because it supports more syntax. For config files read once at startup, this doesn't matter. For high-throughput API communication, stick with standard JSON.

Should I use JSON5 or JSON for my project?

Use JSON5 for human-written configuration files where readability matters. Use standard JSON for API responses, data exchange, and any machine-generated content. JSON5 is a superset of JSON, so valid JSON is always valid JSON5.

Related Tools