↑↓ select ↵ open ⌫ change scope Open full search

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

Functions / Json Functions And Operators

json_strip_nulls

Read the PG 18 manual

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

Reading PG 18current·documented in 13 of 27 versions, 9.5 to 20

Signatures & examples

json_strip_nulls ( target json [,strip_in_arrays boolean ] ) → json
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. 17 → 18 changed
  2. 12 → 13 changed
  3. 9.4 → 9.5 added

Definition snapshot: b7bd9cda · English manual source