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.
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
| Argument | Description |
|---|---|
value | The 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;| reversed | multibyte | empty | null_input |
|---|---|---|---|
| desserts | anañam | NULL |
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;| code | is_palindrome |
|---|---|
| Ledger | false |
| Level | true |
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;| with_reverse | with_array_last |
|---|---|
| summary.pdf | summary.pdf |
Common mistakes
- Passing an array.
REVERSE([1, 2, 3])fails with No matching signature; useARRAY_REVERSE. - Reversing text with combining characters. A decomposed
é(eplus U+0301) is two code points, and REVERSE moves the accent onto the previous letter. ApplyNORMALIZE(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.
Related
Errors you may hit
More string functions
All BigQuery string functions · All functions · BigQuery error messages
