PostgreSQL 18 reference · Array Functions

PostgreSQL ARRAY_TO_STRING() Function

Join array elements into a string with a separator, optionally writing NULLs as a given text.

PostgreSQL 18

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

array_to_string(array, delimiter, null_string)

Parameters

ParameterDescription
array An array value.
delimiter The separator.
null_string optional Text used for NULL elements; otherwise they're skipped.

Return value

text.

Examples

Join elements
SELECT array_to_string(ARRAY['a', 'b', 'c'], ', ') AS joined;

Output

 joined
---------
 a, b, c
(1 row)

Run this on your computer — see “Get Started” for setup.

NULL elements
SELECT array_to_string(ARRAY['a', NULL, 'c'], '-') AS skip, array_to_string(ARRAY['a', NULL, 'c'], '-', '?') AS marked;

Output

 skip | marked
------+--------
 a-c  | a-?-c
(1 row)

Run this on your computer — see “Get Started” for setup.

Was this page helpful?