DEV Community

krunal solanki
krunal solanki

Posted on Edited on

I tested 9 name-matching methods on the OFAC sanctions list. Here's what I found.

If you've ever built customer onboarding for a bank, a lender, a title company or a payments app, you've had to answer one question: is this person on the OFAC sanctions list?

The list is public. The hard part is the name. Customers type "Aymen Zawahri"; the list says "AL ZAWAHIRI, Dr. Ayman". An exact match misses it. A loose fuzzy match flags half your customers named John. And when a compliance analyst asks why a name was flagged, "the library returned 0.87" is not an answer.

I spent ten years building title and mortgage systems, including OFAC screening. This post walks through how I approached name matching in OfacMatch, an open-source screener, with the real numbers at each step. The ideas apply whatever language or library you use.

Why exact matching fails

The Specially Designated Nationals (SDN) list has about 19,500 entries and many more aliases. Real names arrive with:

  • Spelling and transliteration differences: Mohammed, Muhammad, Mohamed
  • Different order: "DOE, John" on the list, "John Doe" in your form
  • Titles and particles: "Dr.", "AL", "BIN"
  • Typos: a missing or swapped letter
  • Extra or missing parts: a middle name the list doesn't have
  • Company suffixes: "EXAMPLE TRADING CO., LTD." versus "Example Trading LLC"

On my held-out test set, exact matching after cleaning up case and punctuation found only 35% of realistic variations of listed names. So you need fuzzy matching, and then you need to keep it from flagging everyone.

Step 1: normalize both names the same way

Before comparing anything, both names go through the same cleanup:

Step Example
Remove accents José Müller → JOSE MULLER
Upper case al-Zawahiri → AL-ZAWAHIRI
Drop apostrophes O'Neil → ONEIL
Other punctuation becomes a space AL-ZAWAHIRI → AL ZAWAHIRI
Remove honorifics Dr. Ayman → AYMAN
Turn LAST, First around (people) AL ZAWAHIRI, Ayman → AYMAN AL ZAWAHIRI
Drop legal forms (companies only) EXAMPLE TRADING CO., LTD. → EXAMPLE TRADING

Two details matter. Legal forms are removed for companies only, never for people. And legal forms are matched even with a one-letter typo ("COMPALY"), because real data is messy.

Step 2: OFAC already tells you how its own tool scores

OFAC publishes how its Sanctions List Search scores names, in its FAQ. It uses two techniques and reports the higher score:

  1. Whole name: Jaro-Winkler similarity of the full strings.
  2. Name parts: compare each part of the name separately, using Jaro-Winkler plus Soundex for parts that sound alike.

OfacMatch uses the same two techniques and the same 0 to 100 scale, so its scores read the way analysts are used to. (It doesn't reproduce OFAC's tool exactly: for example, it applies the Jaro-Winkler prefix bonus only when the base score is above 0.7, as in Winkler's original definition. I haven't yet measured how often the two agree.)

Step 3: score the name parts

Here's the name-parts method on a real pair: searched Aymen Zawahri, listed AL ZAWAHIRI, Dr. Ayman.

  1. Compare every searched part with every listed part using Jaro-Winkler.
  2. If two parts share a Soundex code, raise the score halfway toward 1: (similarity + 1) / 2.
  3. Pair parts greedily from the best pair down; each listed part is used once.
  4. Average the pair scores, weighted by the length of each searched part, so a short particle like "AL" counts less than "ZAWAHIRI".
Searched part Paired with Jaro-Winkler Sounds alike? Part score
AYMEN AYMAN 0.907 yes (A550) 0.953
ZAWAHRI ZAWAHIRI 0.946 yes (Z600) 0.973

Weighted average: (0.953 × 5 + 0.973 × 7) / 12 = 0.965. A small coverage adjustment (5% of the score depends on how much of the listed name was matched; "AL" wasn't) brings it to 95.8.

The whole-name Jaro-Winkler score for the same pair is only 84.5, because "AL" sits in the middle of the listed string. Taking the higher of the two gives 95.8. That's why the two-technique approach works: each one covers the other's blind spots.

Step 4: the false-positive trap, and a guard

"Take the higher of the two" has a problem. Try John Smith against a listed John Numbi:

Score
Whole name (Jaro-Winkler) 88.0
Name parts: JOHN ↔ JOHN 1.000
Name parts: SMITH ↔ NUMBI 0.467
Name parts total 70.4

Jaro-Winkler rewards a long shared prefix, and "JOHN " is a long shared prefix. So the whole-name score says 88, above a typical threshold of 85, for two names that only share a first name.

The fix is one rule:

The whole-name score can only raise the result when every searched part pairs with a listed part scoring at least 0.70.

SMITH ↔ NUMBI scores 0.467, so the whole-name score doesn't count, and the pair scores 70.4: not an alert.

On held-out ordinary names (common first names and surnames from many cultures), this guard cut alerts at a threshold of 85 from 53.0% to 37.5% for two-part names, and from 30.5% to 10.3% for three-part names. Recall on listed-name variations stayed at 100%.

Step 5: explain every score

Every score should come with its reasoning: which name or alias it hit, which technique won, and how each part paired. For the first example, that's the table in Step 3. A reviewer can read it and decide in seconds, and it goes straight into the audit record.

A score also isn't an identity check. "Ivan Hernandez" scores 100 against a listed "HERNANDEZ, Ivan" even if they're different people. So OfacMatch also takes an optional birth year and country, and flags a match whose listed birth year or country disagrees, rather than hiding it. That decision belongs to a person.

How I tested it

Tuning a matcher on the same names you test it on tells you nothing. So I split the work:

  • Development set: used while building and tuning.
  • Held-out set (a different random seed, entries and ordinary names never used in development): used once, for the numbers below.

The held-out set has 4,235 variations of 600 listed people and companies (typos, swapped letters, transliterations, reordering, missing middle names, changed company suffixes), plus 3,000 ordinary names for measuring false alerts. Results at a threshold of 85:

  • 100% of the 4,235 variations found
  • 99.6% of 2,160 harder variations found (wrong first letter like Kassim → Qassim, two wrong letters, nicknames like Aleksandr → Sasha, an initial instead of a first name, an extra middle name)
  • 37.5% of two-part ordinary names and 10.3% of three-part names raise an alert that a person must clear

I also compared eight standard methods on the same data: exact match, Levenshtein, Jaro-Winkler alone, RapidFuzz's token sort and token set ratios, Soundex parts, Monge-Elkan, and trigram TF-IDF. Different methods' scores mean different things, so the fair comparison fixes the alert rate and measures recall:

Method Recall when ≤ 1% of ordinary names alert Recall when ≤ 5% alert
Jaro-Winkler (whole name) 82.7% 85.4%
Levenshtein 85.5% 86.9%
Trigram TF-IDF cosine 93.3% 97.6%
Token sort ratio 95.2% 96.7%
Token set ratio 99.9% 100.0%
OfacMatch (default) 99.2% 100.0%

Token set ratio slightly beats OfacMatch at the strictest alert rate. It's a strong, simple baseline, and if you're building your own matcher it's a good place to start. What it doesn't give you is OFAC's 0-100 scale or a part-by-part explanation an analyst can check.

Full tables, the protocol and the code are in the repo, and there's a paper with the details.

Picking a threshold from data

There's no regulator-approved threshold. OFAC won't recommend one, and "set it to 85" isn't a policy. What you can do is measure the trade-off on data and write down why you chose your number. Here's the trade-off for OfacMatch on the held-out set:

Threshold Variations found Harder variations found Two-part ordinary names alerting Three-part ordinary names alerting
80 100.0% 99.9% 75.7% 51.0%
85 100.0% 99.6% 37.5% 10.3%
90 100.0% 98.4% 10.2% 2.2%
95 99.6% 83.4% 2.1% 0.0%

Three things stand out:

  • Short names drive the alerts. At 85, a two-part name is more than three times as likely to alert as a three-part name. A single global threshold treats them the same; collecting a birth year for every customer is what separates "Daniel Perez" from a listed "PEREZ ROJAS, Daniel".
  • Between 85 and 90, alerts drop by about three quarters while recall on ordinary variations holds. The cost is on the harder cases (99.6% → 98.4%), such as nicknames.
  • At 95, nickname-style variations are mostly missed (42% found). A high threshold looks efficient until someone types "Sasha" instead of "Aleksandr".

Your customers aren't my test set, so run the same kind of test on your own names. A missing birth year should never count against a match; it only means you have less to clear it with.

Try it

The fastest way is the browser page, which runs entirely client-side: krunalsolanki.github.io/ofac-match. Screen one name or a CSV of up to 10,000, and download an audit file.

From Python, run the self-hosted API and use the client:

docker run -p 8080:8080 ghcr.io/krunalsolanki/ofacmatch-api
pip install ofacmatch
Enter fullscreen mode Exit fullscreen mode
from ofacmatch import Client

client = Client("http://localhost:8080")
result = client.screen("Aymen Zawahri", year_of_birth=1951)
for match in result["matches"]:
    print(match["score"], match["listedName"], match["explanation"])

# How two names score, part by part
print(client.compare("John Smith", "John Numbi"))
Enter fullscreen mode Exit fullscreen mode

From .NET:

dotnet add package OfacMatch
Enter fullscreen mode Exit fullscreen mode

There's also an MCP server, so AI assistants like Claude can screen names and explain the results.

Limits

  • It checks the SDN list only, not every US or international list.
  • A person must review every potential match. A score measures how alike two names are written, not whether two records are the same party.
  • It's a screening aid, not legal advice. Pick your threshold from your own risk assessment.

It's free and open source (Apache-2.0): github.com/krunalsolanki/ofac-match. I'd especially like to hear about name variations that score badly; open an issue with the pair and I'll look at it.

Top comments (1)

Collapse
 
gautamtalksdev profile image
Gautam K •

The false-positive guard is the part that matters most for sanctions screening. A missed match is a compliance problem, but too many false hits bury the real ones, so seeing held-out results is great.