select open change scope Open full search

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

FUNCTIONS / JSON FUNCTIONS AND OPERATORS

Converts a given expression specified as text or bytea string (in UTF8 encoding) into a JSON value.

Signatures & examples

json ( expression [ FORMAT JSON [ ENCODING UTF8 ]] [ { WITH | WITHOUT } UNIQUE [ KEYS ]] ) → json
Converts a given expression specified as text or bytea string (in UTF8 encoding) into a JSON value. If expression is NULL, an SQL null value is returned. If WITH UNIQUE is specified, the expression must not contain any duplicate object keys.
json('{"a":123, "b":[true,"foo"], "a":"bar"}') → {"a":123, "b":[true,"foo"], "a":"bar"}
Version history 3
  1. PG 16 → 17added
  2. PG 12 → 13removed
  3. PG 10 → 11added

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