select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / JSON FUNCTIONS AND OPERATORS

jsonb_strip_nulls

Read PG 18 manual ↗

Deletes all object fields that have null values from the given JSON value, recursively.

Signatures & examples

jsonb_strip_nulls ( target jsonb [,strip_in_arrays boolean ] ) → jsonb
Deletes all object fields that have null values from the given JSON value, recursively. If strip_in_arrays is true (the default is false), null array elements are also stripped. Otherwise they are not stripped. Bare null values are never stripped.
json_strip_nulls('[{"f1":1, "f2":null}, 2, null, 3]') → [{"f1":1},2,null,3]
jsonb_strip_nulls('[1,2,null,3,4]', true) → [1,2,3,4]
Version history 3
  1. PG 17 → 18changed
  2. PG 12 → 13changed
  3. PG 9.4 → 9.5added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source