↑↓ select ↵ open ⌫ change scope Open full search

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

Functions / Json Functions And Operators

array_to_json

Read the PG 18 manual

Converts an SQL array to a JSON array.

Reading PG 18current·documented in 16 of 27 versions, 9.2 to 20

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. 13 → 14 changed
  2. 12 → 13 changed
  3. 9.3 → 9.4 changed
  4. 9.2 → 9.3 changed
  5. 9.1 → 9.2 added

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