Request a demo

BigQuery · String function

BigQuery REVERSE

REVERSE(value) returns a STRING with its characters in reverse order, or a BYTES value with its bytes reversed: REVERSE('stressed') returns desserts. For arrays, use ARRAY_REVERSE.

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

REVERSE flips the order of the characters in a STRING, or of the bytes in a BYTES value. For STRING it works on Unicode characters, so multi-byte characters such as ñ stay intact. Characters built from several code points, such as a letter followed by a combining accent, are reversed code point by code point, so the accent can end up on a different letter.

NULL returns NULL and an empty string returns an empty string. REVERSE doesn't accept arrays; use ARRAY_REVERSE.

On its own REVERSE is mostly used for palindrome checks and test data. Older SQL used it to find the last occurrence of a character; in BigQuery, INSTR(value, '/', -1) or ARRAY_LAST(SPLIT(value, '/')) does that more directly.

Syntax

REVERSE(value)

Arguments and return value

ArgumentDescription
valueThe STRING or BYTES value to reverse.

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

Examples

Reverse strings

SELECT
  REVERSE('stressed') AS reversed,
  REVERSE('mañana') AS multibyte,
  REVERSE('') AS empty,
  REVERSE(CAST(NULL AS STRING)) AS null_input;
Result
reversedmultibyteemptynull_input
dessertsanañamNULL

Palindrome check

WITH codes AS (
  SELECT 'Level' AS code UNION ALL
  SELECT 'Ledger'
)
SELECT code, LOWER(code) = LOWER(REVERSE(code)) AS is_palindrome
FROM codes
ORDER BY code;
Result
codeis_palindrome
Ledgerfalse
Leveltrue

Last path segment, old way and new way

SELECT
  REVERSE(SPLIT(REVERSE('reports/2026/q4/summary.pdf'), '/')[OFFSET(0)]) AS with_reverse,
  ARRAY_LAST(SPLIT('reports/2026/q4/summary.pdf', '/')) AS with_array_last;
Result
with_reversewith_array_last
summary.pdfsummary.pdf

Common mistakes

  • Passing an array. REVERSE([1, 2, 3]) fails with No matching signature; use ARRAY_REVERSE.
  • Reversing text with combining characters. A decomposed é (e plus U+0301) is two code points, and REVERSE moves the accent onto the previous letter. Apply NORMALIZE(value) first.
  • Reversing BYTES that hold UTF-8 text. Byte-wise reversal breaks multi-byte characters; reverse the STRING instead.

FAQ

How do I reverse an array in BigQuery?

Use ARRAY_REVERSE. REVERSE works only on STRING and BYTES.

How do I find the last occurrence of a character without REVERSE?

Use INSTR(value, 'x', -1), which searches backwards and returns the position counted from the start.

Errors you may hit

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.