Why this matters
`jsonb` stores a parsed representation, supports GIN indexes, and is what application code almost always wants. `json` is only the right choice if you specifically need byte-exact round-tripping of input text. Pick one direction with the `style` option.
Examples
Incorrect
CREATE TABLE events (payload JSON);Correct
CREATE TABLE events (payload JSONB);Configure it
// eslint.config.js
import postgresql from "eslint-plugin-postgresql";
export default [
{
files: ["**/*.sql"],
languageOptions: {
parser: postgresql.configs.recommended.languageOptions.parser,
},
plugins: { postgresql },
rules: {
"postgresql/consistent-jsonb-over-json": [
"warn",
{
style: "always",
},
],
},
},
]; Options
Edit the SQL — only consistent-jsonb-over-json is enabled.
Pre-filled with the first incorrect example. Toggle off in the rule shelf to see how the diagnostic disappears.
Diagnostics
No issues found.
2 rules enabled.
Rule under test
consistent-jsonb-over-json — plus no-syntax-error as a safety net.