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_serialize

Read PG 18 manual ↗

Converts an SQL/JSON expression into a character or binary string.

Signatures & examples

json_serialize ( expression [ FORMAT JSON [ ENCODING UTF8 ] ] [ RETURNING data_type [ FORMAT JSON [ ENCODING UTF8 ] ] ] )
Converts an SQL/JSON expression into a character or binary string. The expression can be of any JSON type, any character string type, or bytea in UTF8 encoding. The returned type used in RETURNING can be any character string type or bytea. The default is text.
json_serialize('{ "a" : 1 } ' RETURNING bytea) → \x7b20226122203a2031207d20
Version history 1
  1. PG 16 → 17added

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