Back to Blog

Compare Text in Google Sheets with EXACT

Case-sensitive text comparison with EXACT, plus practical patterns for deduping and validation.

Aug 7th, 2026SheetFX

Compare Text in Google Sheets with EXACT

August 7th, 2026

Text comparison in Google Sheets looks simple until case, spaces, or look-alike values trip you up. The = operator is case-insensitive for text, so "Apple" = "apple" is true. When you need a strict, character-by-character match — passwords, codes, IDs, or validation rules — use EXACT. This guide covers how EXACT works, how it differs from =, and practical patterns with TRIM and UPPER for both strict and “fuzzy” equality.

What EXACT does

EXACT compares two strings and returns TRUE only if they are identical, including letter case. Spaces, punctuation, and invisible differences all count.

=EXACT("SheetFX", "SheetFX")
=EXACT("SheetFX", "sheetfx")
=EXACT("A1", "A1 ")

The first formula returns TRUE. The second returns FALSE because of case. The third returns FALSE because of the trailing space. That strictness is the point: EXACT never silently “helps” you by ignoring case or padding.

You can pass cell references the same way:

=EXACT(A2, B2)

EXACT vs the = operator

For numbers and pure logic, = is fine. For text, behavior differs:

="Apple"="apple"
=EXACT("Apple", "apple")

The first returns TRUE (case-insensitive equality). The second returns FALSE. Use = when human-friendly matching is enough (e.g. a status label that might be typed in mixed case). Use EXACT when the string is a key: coupon codes, employee IDs, product SKUs, checksum fragments, or anything where case is part of the value.

Another subtle difference: EXACT always treats both arguments as text for comparison purposes, which keeps mixed-type edge cases more predictable when one side might look numeric.

Building fuzzy equality on purpose

Strict matching is not always what you want. Often you need “same content after cleanup.” Combine EXACT with cleanup functions so the rule is explicit instead of accidental.

Ignore leading and trailing spaces

=EXACT(TRIM(A2), TRIM(B2))

TRIM removes extra spaces at the ends (and collapses repeated internal spaces in Google Sheets). Pairing TRIM with EXACT is a common validation pattern when users paste values from email or CSVs.

Case-insensitive but still “exact” otherwise

=EXACT(UPPER(A2), UPPER(B2))

Or with both cleanup steps:

=EXACT(UPPER(TRIM(A2)), UPPER(TRIM(B2)))

That formula is true when the values match after normalizing case and outer/internal spacing. You get controlled fuzzy equality: case and spaces are ignored, but characters still must match. Prefer this over raw = when you want a readable, intentional rule.

Normalize before compare (IDs and codes)

For codes that should never contain spaces:

=EXACT(SUBSTITUTE(UPPER(A2), " ", ""), SUBSTITUTE(UPPER(B2), " ", ""))

That strips every space and uppercases both sides before EXACT runs — useful for membership numbers or coupon codes entered with accidental gaps.

Practical validation use cases

Confirm a confirmation field matches

Two cells must contain the same email or code (case-sensitive if required):

=IF(EXACT(A2, B2), "Match", "Does not match")

For email, you usually want case-insensitive matching:

=IF(EXACT(LOWER(TRIM(A2)), LOWER(TRIM(B2))), "Match", "Does not match")

Flag rows that changed after import

If column A is the source system value and column B is the edited sheet value:

=IF(EXACT(A2, B2), "", "Changed")

Because EXACT is case-sensitive, a change from "NY" to "ny" is detected — something A2=B2 would miss.

Deduping with a helper column

When two columns should form a unique pair only when both strings match exactly:

=EXACT(A2, C2)

Filter or COUNTIF on the helper column to find true duplicates under strict rules. For case-insensitive dedupe keys, build a normalized key first:

=UPPER(TRIM(A2))

Then count that key column instead of relying on =.

Data validation formula

In Data → Data validation → Custom formula, require that the entry in B2 matches a master code in A2:

=EXACT(B2, A2)

Or allow case-insensitive match against a list value in A2:

=EXACT(UPPER(B2), UPPER(A2))

Conditional formatting for mismatches

Highlight cells where the value does not match a reference:

=NOT(EXACT(A2, $B$2))

Apply that rule to a range starting at A2 to surface typos against a fixed expected string.

EXACT inside IF, FILTER, and arrays

EXACT returns a boolean, so it plugs into any logical formula:

=IF(EXACT(A2, "ACTIVE"), "Keep", "Drop")

With FILTER, keep only rows where a status column matches exactly:

=FILTER(A2:C100, EXACT(B2:B100, "Open"))

Note: array use of EXACT works in modern Sheets the same way other element-wise comparisons do — each pair is evaluated, and you get a column of TRUE/FALSE that FILTER can use.

Common mistakes

  • Expecting EXACT to ignore case. It never does. Use UPPER/LOWER (or plain =) when case should not matter.
  • Invisible spaces. "code" and "code " fail EXACT. Prefer TRIM on both sides when human input is involved.
  • Non-breaking spaces and special characters. TRIM does not always remove every Unicode space variant. If paste quality is poor, clean with SUBSTITUTE or CLEAN first.
  • Using EXACT for numbers when you mean numeric equality. EXACT(1, "1") can surprise you depending on how values are stored. For numbers, prefer = or ROUND-based checks; reserve EXACT for text keys.
  • Assuming = is always safer. For IDs and codes, silent case-insensitivity hides real differences. Prefer EXACT (optionally with explicit normalization) for keys.

Which approach should you pick?

| Goal | Approach | | --- | --- | | Case-sensitive identity | EXACT(A, B) | | Case-insensitive, spaces matter | EXACT(UPPER(A), UPPER(B)) or A=B | | Trimmed, case-insensitive | EXACT(UPPER(TRIM(A)), UPPER(TRIM(B))) | | Human-friendly status labels | = is usually enough | | Codes, SKUs, validation keys | EXACT, with optional UPPER/TRIM |

Going further

EXACT is a small function with a clear job: tell you whether two strings are truly the same. Combine it with TRIM, UPPER, LOWER, and SUBSTITUTE when you need controlled cleanup; keep raw EXACT when case and spacing are part of the contract. For broader text cleanup patterns, see Working with Text Functions in Google Sheets and the reference page for EXACT.

Newsletter

Get weekly Sheets tips in your inbox.

Short, practical Google Sheets and Apps Script updates — no noise, just formulas that work.