ParseJSON LogoParseJSON

JSON vs JSON5

JSON5 is a superset of JSON proposed in 2012 to make hand-authored configuration files less painful. It’s used by Babel, ESLint (older versions), and various build tools. It’s not suitable for API data interchange.

What JSON5 Adds

Standard JSON
{
  "name": "Alice",
  "age": 30
}
JSON5
{
  // A comment
  name: 'Alice',    // unquoted key
  age: 30,          // trailing comma
}

JSON5 additions:

  • Comments: // single-line and /* */ block comments
  • Trailing commas: allowed after last object key or array item
  • Single-quoted strings: for keys and values
  • Unquoted keys: when they are valid JavaScript identifiers
  • Hexadecimal numbers: 0xFF
  • Infinity / NaN: valid number values
  • Multi-line strings: escape the newline with \\

When to Use JSON

  • REST API request and response bodies
  • Data storage and interchange between services
  • Anywhere the consumer is JSON.parse() — it only handles standard JSON

When to Use JSON5

  • Configuration files you write by hand (like .babelrc)
  • Developer tooling that explicitly supports JSON5 parsing
  • Situations where comments and trailing commas significantly improve maintainability
If your parser is JSON.parse(), you need standard JSON. If your tooling specifically uses a JSON5 parser, you can use JSON5 features. Mixing them up is the source of many confusing parse errors.

ParseJSON and JSON5

ParseJSON uses JSON.parse(), so it validates and formats standard JSON only. If your file is JSON5, you need to strip comments and trailing commas before pasting it here.

Related