Request a demo

BigQuery · String function

BigQuery TRANSLATE

TRANSLATE(value, source_chars, target_chars) replaces each character in source_chars with the character at the same position in target_chars, and deletes source characters that have no counterpart: TRANSLATE(phone, '()- ', '') strips four characters in one call.

GoogleSQL for BigQuery · Checked against the official reference in November 2026

TRANSLATE works one character at a time. For each character of expression, it looks the character up in source_characters; if it is there, it is replaced by the character at the same position in target_characters, or removed when target_characters is shorter. Characters not in the source list are left alone. Extra characters at the end of target_characters are ignored.

Each character is translated at most once, so mappings don't chain: TRANSLATE('abc', 'ab', 'ba') swaps a and b and returns bac. A character listed twice in source_characters is an error. All three arguments must have the same type, STRING or BYTES, and NULL in any of them returns NULL.

TRANSLATE is the right tool for character-level cleanup: removing punctuation, mapping separators, or replacing a fixed list of accented letters. To replace whole words or multi-character sequences, use REPLACE; for classes of characters such as "everything that isn't a digit", use REGEXP_REPLACE.

Syntax

TRANSLATE(expression, source_characters, target_characters)

Arguments and return value

ArgumentDescription
expressionThe STRING or BYTES value to change.
source_charactersThe characters to replace or remove. No duplicates.
target_charactersThe replacement for each source character, by position. Source characters beyond its length are deleted.

Returns: STRING or BYTES, the same type as expression.

Examples

Remove and map characters

SELECT
  TRANSLATE('+1 (415) 555-0100', '()- ', '') AS removed,
  TRANSLATE('2026/11/23', '/', '-') AS mapped,
  TRANSLATE('Crème Brûlée', 'èûé', 'eue') AS accents,
  TRANSLATE('abc', 'ab', 'ba') AS swapped;
Result
removedmappedaccentsswapped
+141555501002026-11-23Creme Bruleebac

Shorter and longer target lists

In shorter_target, - maps to . and _ has no counterpart, so it is deleted. In longer_target, the extra y is ignored.

SELECT
  TRANSLATE('a-b_c', '-_', '.') AS shorter_target,
  TRANSLATE('abc', 'a', 'xy') AS longer_target;
Result
shorter_targetlonger_target
a.bcxbc

Normalize product codes before a join

WITH supplier AS (
  SELECT 'AB-12.7' AS supplier_code UNION ALL
  SELECT 'CD 99/1'
)
SELECT supplier_code, UPPER(TRANSLATE(supplier_code, '-. /', '')) AS normalized_code
FROM supplier
ORDER BY supplier_code;
Result
supplier_codenormalized_code
AB-12.7AB127
CD 99/1CD991

Common mistakes

  • Using TRANSLATE to replace words. TRANSLATE(status, 'paid', 'done') maps the letters p, a, i, d to d, o, n, e everywhere in the string; use REPLACE for substrings.
  • Listing a character twice in the source. TRANSLATE(s, 'aa', 'xy') fails with Duplicate character "a" in TRANSLATE source characters.
  • Expecting chained replacements. Each character is translated once, so mapping a to b and b to c turns ab into bc, not cc.
  • Trying to remove all accents with a short list. TRANSLATE only knows the characters you list; for general accent removal, REGEXP_REPLACE(NORMALIZE(s, NFD), r'\pM', '') removes all combining marks.

FAQ

How do I remove several characters from a string at once in BigQuery?

Put them in the source list and pass an empty target: TRANSLATE(value, '()-. ', ''). Every listed character is deleted.

What is the difference between TRANSLATE and REPLACE?

REPLACE swaps whole substrings ('pie' to 'cake'). TRANSLATE maps single characters by position and can replace or delete many different characters in one pass.

Does BigQuery TRANSLATE work like Oracle and PostgreSQL TRANSLATE?

Yes for the core behaviour: characters map by position and source characters without a target are removed. BigQuery also raises an error for duplicate source characters.

More string functions

All BigQuery string functions · All functions · BigQuery error messages

Observability for every BigQuery table, in about 15 minutes

Masthead detects freshness, volume and schema anomalies, monitors pipeline errors and maps column-level lineage across all your projects, from logs and metadata only.