jsonc-eslint-parser is a dedicated parser for ESLint that enables linting of JSON, JSONC (JSON with comments), and JSON5 files. Its current stable version is v3.1.0, and it maintains an active release cadence with regular minor and patch updates following major version bumps. This parser differentiates itself by providing a robust Abstract Syntax Tree (AST) specifically tailored for ESLint's linting capabilities, making it an essential component for projects requiring strict code style and error checking within various JSON formats. It is frequently used in conjunction with `eslint-plugin-jsonc` to provide comprehensive rule sets. The library ships with TypeScript types, facilitating its use in TypeScript-based configurations and projects.
npm install jsonc-eslint-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to configure jsonc-eslint-parser in an ESLint flat configuration file (`eslint.config.js` or `eslint.config.mjs`) to parse JSON, JSONC, and JSON5 files.
Upgrade your Node.js environment to a supported version (>=20.19.0 || >=22.13.0 || >=24). If unable to upgrade, stick to jsonc-eslint-parser v2.x.
Remove or loosen `parserOptions.jsonSyntax` from your ESLint config. Instead, install and configure `eslint-plugin-jsonc` and apply its specific rules (e.g., `jsonc/no-comments` for strict JSON) to manage syntax strictness.
Ensure the `files` array in your ESLint configuration (e.g., `files: ['**/*.json', '**/*.json5', '**/*.jsonc']`) correctly targets all JSON-like files you intend this parser to handle.
Change `parser: 'jsonc-eslint-parser'` to `parser: jsoncParser` after importing it as `import * as jsoncParser from 'jsonc-eslint-parser';`.
Verify that your `files` array in the ESLint configuration correctly targets your JSON files and that the `languageOptions.parser` is set to `jsoncParser` for those files. Also check for Node.js version compatibility (v3.0.0+ requires Node.js >=20.19.0).
Either loosen or remove the `parserOptions.jsonSyntax` option, or ensure it matches the specific flavor of JSON/JSONC/JSON5 you are parsing. Also, ensure you are on the latest compatible version of `jsonc-eslint-parser`.