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 an SQL array to a JSON array.

Signatures & examples

array_to_json ( anyarray [, boolean ] ) → json
Converts an SQL array to a JSON array. The behavior is the same as to_json except that line feeds will be added between top-level array elements if the optional boolean parameter is true.
array_to_json('{{1,5},{99,100}}'::int[]) → [[1,5],[99,100]]
Version history 5
  1. PG 13 → 14changed
  2. PG 12 → 13changed
  3. PG 9.3 → 9.4changed
  4. PG 9.2 → 9.3changed
  5. PG 9.1 → 9.2added

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