PostgreSQL 18 reference · String Functions

PostgreSQL TRANSLATE() Function

Replace single characters by position: each character in 'from' becomes the matching character in 'to', or is deleted.

PostgreSQL 18

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

Syntax

translate(string, from, to)

Parameters

ParameterDescription
string The input text.
from Characters to replace.
to Replacements, matched by position; missing ones delete.

Return value

Text.

Examples

Character by character
SELECT translate('2026-01-05', '-', '.') AS dotted, translate('hello', 'el', 'ip') AS swapped;

Output

   dotted   | swapped
------------+---------
 2026.01.05 | hippo
(1 row)

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

Delete characters
SELECT translate('+1 (555) 010-9999', '+() -', '') AS digits_only;

Output

 digits_only
-------------
 15550109999
(1 row)

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

Was this page helpful?