Registry / testing / eslint-plugin-json

eslint-plugin-json

JSON →
library4.0.1jsnpmunverified

ESLint plugin for linting JSON files. Version 4.0.1 supports ESLint flat config and requires Node >=18. It uses VSCode's JSON parser for linting, replacing JSHint in v1.3.1. Recommended for ensuring valid JSON, catching duplicate keys, trailing commas, and other issues. Supports allowing comments. The plugin ships with recommended configs for both flat and legacy ESLint formats.

npm install eslint-plugin-json
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-JSON
E
eslint-plugin-json
testingjavascriptv4.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import json from 'eslint-plugin-json'
ESM import for flat config (ESLint v9+). Also works with require in legacy.
json
import json from 'eslint-plugin-json'
Import the plugin object for flat config.
configs (recommended)
json.configs['recommended']
Access recommended config for flat config.
configs (recommended-legacy)
json.configs['recommended-legacy']
Access legacy recommended config for .eslintrc.

Basic flat config setup to lint all .json files using the recommended config.

// eslint.config.js (flat config) import json from 'eslint-plugin-json'; export default [ { files: ['**/*.json'], ...json.configs['recommended'] } ]; // Then run: npx eslint . --ext .json
Debug
Known issues
breakingESLint v9+ requires flat config; plugin v4+ needed.
fix
Use eslint-plugin-json v4+ and flat config format (eslint.config.js).
affects: >=9
breakingESLint v9 dropped --ext flag support for some formats; use files in flat config.
fix
Define files glob in eslint.config.js instead of --ext .json.
affects: >=9
gotchaThe rule json/* applies all linting rules; configuring individual rules may override.
fix
Use individual rules like 'json/undefined' for granular control, or set severity on json/*.
affects: >=1.0
gotchaLegacy configs (recommended-legacy) are deprecated in favor of flat config.
fix
Migrate to flat config and use recommended config.
affects: >=4.0
deprecatedUse of .eslintrc config format is deprecated for new projects with ESLint v9+.
fix
Switch to eslint.config.js (flat config).
affects: >=9
Errors
Common errors & fixes
Failed to load plugin 'json': Cannot find module 'eslint-plugin-json'
Plugin not installed or not in node_modules.
fix
npm install --save-dev eslint-plugin-json
ESLint: Error while loading rule 'json/undefined': Rule not found
Legacy config using individual rules without specifying processor.
fix
Add processor: 'json/json' in flat config or use recommended config.
ESLint: Expected linebreaks to be 'LF' but found 'CRLF'
This rule is from another plugin (e.g., eslint-plugin-linebreak), not this one.
fix
This is not a json plugin issue; configure linebreak-style rule elsewhere.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency - plugin requires ESLint to run
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-json — npm install eslint-plugin-json · libregistry