Address Standardization and Fuzzy Matching: How to Deduplicate by Street Address
Ask a human: are these the same address?
123 Main Street, Apt 4B, San Francisco, CA 94103123 MAIN ST #4B, SAN FRANCISCO CA 94103-2201
Obviously yes. Ask a database with a naive fuzzy scorer and you'll get a token similarity of about 60% — below most sensible thresholds. Same address, treated as different records, silently inflating your customer count, your direct mail budget, and your ad audiences.
The trick isn't a better fuzzy scorer. The trick is standardization: parse the address into structured components before you compare. This guide walks through the full standardize-and-match workflow for US and international addresses, with runnable examples and the trade-offs of each approach.
What's in this guide
- Why address matching is uniquely hard
- The four approaches, ranked
- Level 1: Regex-based normalization (free, works pretty well)
- Level 2: libpostal parsing (free, works really well)
- Level 3: USPS/Smarty/Loqate validation APIs (paid, works best)
- Then: how to actually match the standardized addresses
- Household matching: same address, different people
- International address matching
- A complete standardize + match pipeline
- FAQ
Why Address Matching Is Uniquely Hard
Names and emails have one canonical form each. Addresses have dozens. The same delivery location can be written as:
123 Main St/123 Main Street/123 Main St.Apt 4B/Apartment 4B/#4B/Unit 4B/Ste 4BN Main St/North Main Street/Main St N94103/94103-2201/94103 2201CA/Calif/CaliforniaPO Box 123/P.O. Box 123/Post Office Box 123- Language variants:
Rue de la Paixvsrue Paix - Field-order variants: everything above but with the pieces in a different order because a CSV upload flipped them
Multiply all of these together and any given address has thousands of possible surface forms. A pure fuzzy match tries to bridge them with edit distance; it's underpowered for the job. Standardization — parsing the address into structured fields and rewriting each field in a canonical form — is the shortcut that lets a simple exact-match do most of the work.
The Four Approaches, Ranked
| Approach | Cost | Recall | Corrects typos? | Best for |
|---|---|---|---|---|
| Fuzzy match raw strings | Free | 60–75% | Sort of | Small datasets, one-off cleanup |
| Regex normalization + fuzzy match | Free | 85–90% | No | Most in-house work |
| libpostal parse + exact match on components | Free | 92–95% | No | Multi-country data at scale |
| USPS/Smarty/Loqate API + exact match | $$ | 97–99% | Yes | Shipping, compliance, high-stakes |
Which one to pick isn't obvious — it depends on whether typos matter to you and whether you have budget for an API. Below, the actual details of each.
Level 1: Regex-Based Normalization
The cheapest approach that materially helps. Write a normalizer that applies USPS Publication 28 abbreviations and a few common cleanups, and you'll close ~70% of the standardization gap without a single external dependency.
import re
STREET_SUFFIX = {
'street': 'st', 'st.': 'st',
'avenue': 'ave', 'ave.': 'ave', 'av': 'ave',
'boulevard': 'blvd', 'blvd.': 'blvd',
'road': 'rd', 'rd.': 'rd',
'drive': 'dr', 'dr.': 'dr',
'lane': 'ln', 'ln.': 'ln',
'court': 'ct', 'ct.': 'ct',
'place': 'pl', 'pl.': 'pl',
'square': 'sq', 'sq.': 'sq',
'parkway': 'pkwy', 'pkwy.': 'pkwy',
'highway': 'hwy', 'hwy.': 'hwy',
}
DIRECTIONAL = {
'north': 'n', 'south': 's', 'east': 'e', 'west': 'w',
'northeast': 'ne', 'northwest': 'nw',
'southeast': 'se', 'southwest': 'sw',
}
SECONDARY = {
'apartment': 'apt', 'apt.': 'apt',
'suite': 'ste', 'ste.': 'ste',
'unit': 'unit', 'building': 'bldg',
'floor': 'fl', 'fl.': 'fl',
'#': 'apt',
}
def normalize_address(s):
if not s: return ''
s = s.lower().strip()
s = re.sub(r'[.,]', ' ', s) # drop commas & periods
s = re.sub(r'\s+', ' ', s) # collapse whitespace
tokens = s.split(' ')
out = []
for t in tokens:
if t in STREET_SUFFIX: out.append(STREET_SUFFIX[t])
elif t in DIRECTIONAL: out.append(DIRECTIONAL[t])
elif t in SECONDARY: out.append(SECONDARY[t])
else: out.append(t)
return ' '.join(out)
>>> normalize_address('123 Main Street, Apt 4B')
'123 main st apt 4b'
>>> normalize_address('123 MAIN ST #4B')
'123 main st apt 4b'
>>> normalize_address('123 North Main Boulevard')
'123 n main blvd'
Two addresses that go through this normalizer will collide exactly if they're the same address in USPS-abbreviated form. That means you can now use a plain df.merge() or a set-membership check for the exact-match tier, and only fall back to fuzzy matching for the residuals.
This is fast, offline, and free — but it doesn't fix typos (Mian St stays as Mian St) and it doesn't handle non-English addresses.
Level 2: libpostal Parsing
libpostal is an open-source C library trained on ~1 billion OpenStreetMap addresses. It parses arbitrary international address strings into structured components, and expands abbreviations. It is the most under-used tool in the address-cleanup toolkit.
# pip install postal (requires libpostal installed system-side)
from postal.parser import parse_address
from postal.expand import expand_address
>>> parse_address("123 Main St Apt 4B San Francisco CA 94103")
[('123', 'house_number'),
('main st', 'road'),
('apt 4b', 'unit'),
('san francisco', 'city'),
('ca', 'state'),
('94103', 'postcode')]
>>> expand_address("123 Main St")
['123 main street', '123 main saint']
Once addresses are parsed into components, matching becomes trivial: compare house_number, road, city, state, postcode field-by-field. Two addresses are the same if their house_number, normalized road, and postcode match — independent of what order the tokens appeared in the raw string.
import pandas as pd
from postal.parser import parse_address
def parse_to_dict(addr):
return dict((v, k) for k, v in parse_address(addr))
def address_key(addr):
p = parse_to_dict(addr)
return (
p.get('house_number', ''),
p.get('road', ''),
p.get('postcode', '')[:5], # first 5 digits of zip
)
df['_addr_key'] = df['address_full'].apply(address_key)
# Group by key = exact match on the standardized components
groups = df.groupby('_addr_key').size().reset_index(name='count')
libpostal's parser gets ~99% accuracy on US addresses and ~90–95% on international ones. The main drawback is installation: it's a C library, and pip won't help you if libpostal itself isn't installed on the system. On Ubuntu it's a apt install libpostal-dev + pip install postal; on Mac use Homebrew; on Windows use WSL. For a hosted option, several APIs wrap libpostal as a service.
Level 3: USPS/Smarty/Loqate Validation APIs
If typos matter — and they do if you ship physical goods or file 1099s — the parsers above aren't enough. You need validation: checking the address against a live postal database and getting back the canonical, deliverable form.
Options:
- USPS Web Tools API — free, US-only, low throughput (rate-limited). Good for small verification passes.
- Smarty (formerly SmartyStreets) — commercial, US + international, fast, well-documented. The default for most engineering teams.
- Loqate — commercial, strong international coverage, integrates with Salesforce.
- Google Places / Address Validation API — commercial, global, priced per lookup. Best when you also want geocoding.
- Melissa Data — commercial, US enterprise focus, batch-friendly.
The output is a normalized deliverable address plus a status code (Deliverable, Deliverable with suffix change, Undeliverable, Multiple candidates). For dedup, treat two records with the same USPS-verified DPBC (delivery point barcode) as the same address, period. That's a mailhouse-grade dedup that catches everything the regex tier misses.
Cost math for validation APIs: Smarty and Loqate both price in the $0.005–$0.02 per lookup range for volumes over 100k. For a one-time 500k-row cleanup that's $2,500–$10,000 — usually much cheaper than a mail waste event from bad addresses, but check the ROI before signing.
Then: How to Actually Match the Standardized Addresses
Standardization gets you 90% of the way. Matching finishes the job. Two tiers work well in practice:
Tier 1: Exact match on the address key
After standardization, most true duplicates collide exactly. A simple GROUP BY or drop_duplicates on the normalized key handles them:
df['_key'] = df['address_normalized'] + '|' + df['zip'].str[:5]
df['dup_group'] = df.groupby('_key').ngroup()
Tier 2: Fuzzy match on the residual
The 5–10% of records that don't collide exactly are usually typos or edge cases (missing suite number, transposed digits in the house number). For those, run a fuzzy pass:
from rapidfuzz import fuzz, process
# Only compare within the same zip+city (blocking!)
for (zip5, city), group in df.groupby([df['zip'].str[:5], 'city_norm']):
if len(group) < 2: continue
keys = group['address_normalized'].tolist()
scores = process.cdist(keys, keys, scorer=fuzz.token_set_ratio)
# threshold ~90 catches typos without false positives
See our Pandas fuzzy matching guide for the full process.cdist pattern and blocking strategy.
What threshold should I use?
For post-standardization address matching, token_set_ratio >= 90 is a good default. Below 85 you start pulling in same-street-different-house pairs (123 Main St vs 133 Main St) as false positives, which is dangerous. If you can't tolerate any false positives — e.g., you're using this for shipping deduplication — require exact match on house_number as a pre-condition and only fuzzy-match the street name.
Household Matching: Same Address, Different People
A special case that comes up constantly: two people with different names at the same address. Are they duplicates?
Depends what you're doing:
- Direct mail: yes, usually. One piece per household is standard. Group by address; keep one per group.
- CRM contacts: no, they're separate people. But tag them with a shared
household_idso marketing campaigns can suppress within-household duplicates when appropriate. - Fraud/AML: flag it, don't merge. Multiple identities at one address is a signal worth reviewing.
- B2B accounts: almost certainly not duplicates — multiple buyers at one company address is the norm. Don't dedup on address alone for B2B.
The pattern is always the same: group by standardized address (assign a household ID), then decide per use case whether to merge, suppress, or keep separate.
df['household_id'] = df.groupby(
['address_normalized', 'zip5', 'city_norm']
).ngroup()
# One piece per household, most recent contact wins
household_dedup = (
df.sort_values('last_contacted_at', ascending=False)
.drop_duplicates('household_id', keep='first')
)
International Address Matching
Every country has its own address grammar. The US puts state before zip; France puts postcode before city; Japan writes largest-to-smallest (prefecture → city → ward → block → number). Trying to match international addresses with a US-shaped normalizer produces garbage.
The rules that work:
- Always route by country first. Split the data on the
countryfield (or infer it from ZIP/postcode format) before any standardization. - Use libpostal for anything non-US. It's trained on international OSM data and handles ~60 languages. Roll-your-own regex normalizers won't cover Sweden.
- Never match across countries. The number of records in your data that are actually the same address in two different countries is zero. Match only within-country pairs.
- Normalize postcodes to their country's canonical format. UK postcodes have a space; German ones don't; Canadian ones alternate letter-digit. Get each one right and postcode becomes an incredibly strong blocking key.
For truly global data at scale, a validation API (Loqate, Melissa Global, Google) is usually more cost-effective than trying to maintain per-country normalizers in-house.
A Complete Standardize + Match Pipeline
Putting it together, here's a pipeline you can drop into a script or a scheduled job. This is the regex-tier version; swap in libpostal for the parse step if you need higher accuracy.
import pandas as pd
import re
from rapidfuzz import fuzz, process
import numpy as np
import networkx as nx
# --- 1. NORMALIZE ------------------------------------------------------------
def normalize_address(s):
if pd.isna(s) or not s: return ''
s = str(s).lower().strip()
s = re.sub(r'[.,]', ' ', s)
s = re.sub(r'\s+', ' ', s)
for pat, repl in [
(r'\bstreet\b', 'st'), (r'\bavenue\b', 'ave'),
(r'\bboulevard\b', 'blvd'), (r'\broad\b', 'rd'),
(r'\bdrive\b', 'dr'), (r'\blane\b', 'ln'),
(r'\bnorth\b', 'n'), (r'\bsouth\b', 's'),
(r'\beast\b', 'e'), (r'\bwest\b', 'w'),
(r'\bapartment\b', 'apt'), (r'\bsuite\b', 'ste'),
(r'\bunit\b', 'unit'), (r'#\s*', 'apt '),
]:
s = re.sub(pat, repl, s)
return s.strip()
def normalize_zip(z):
if pd.isna(z): return ''
z = re.sub(r'\D', '', str(z))
return z[:5]
# --- 2. LOAD & STANDARDIZE ---------------------------------------------------
df = pd.read_csv('customers.csv')
df['_addr_n'] = df['address'].apply(normalize_address)
df['_zip5'] = df['zip'].apply(normalize_zip)
df['_city_n'] = df['city'].fillna('').str.lower().str.strip()
# --- 3. TIER 1: EXACT MATCH ON KEY -------------------------------------------
df['_key'] = df['_addr_n'] + '|' + df['_zip5']
df['exact_group'] = df.groupby('_key').ngroup()
# --- 4. TIER 2: FUZZY MATCH WITHIN ZIP+CITY BLOCKS ---------------------------
pairs = []
for (zip5, city), group in df.groupby(['_zip5', '_city_n']):
if len(group) < 2: continue
vals = group['_addr_n'].tolist()
idx = group.index.tolist()
m = process.cdist(vals, vals, scorer=fuzz.token_set_ratio)
for i in range(len(vals)):
for j in range(i+1, len(vals)):
if m[i, j] >= 90:
pairs.append((idx[i], idx[j], float(m[i, j])))
# --- 5. CLUSTER PAIRS INTO GROUPS --------------------------------------------
G = nx.Graph()
G.add_nodes_from(df.index)
G.add_edges_from((a, b) for a, b, _ in pairs)
# Add tier-1 exact matches as edges too
for _, g in df.groupby('_key'):
ids = g.index.tolist()
for i in range(len(ids)):
for j in range(i+1, len(ids)):
G.add_edge(ids[i], ids[j])
groups = np.full(len(df), -1)
for gid, comp in enumerate(nx.connected_components(G)):
for idx in comp:
groups[df.index.get_loc(idx)] = gid
df['address_group'] = groups
# --- 6. PICK A SURVIVOR PER GROUP --------------------------------------------
survivors = (
df.sort_values(['last_updated', '_addr_n'], ascending=[False, True])
.drop_duplicates('address_group', keep='first')
.drop(columns=['_addr_n', '_zip5', '_city_n', '_key', 'exact_group'])
)
survivors.to_csv('deduped_by_address.csv', index=False)
print(f'{len(df)} rows → {len(survivors)} unique addresses')
Run this on a real customer file and you'll usually see a 5–20% collapse. Depending on the source, that's 5,000–20,000 duplicate mailings, ad impressions, or CRM records eliminated in one pass.
FAQ
Do I need address validation, or is standardization enough?
Depends on the cost of a wrong address. For CRM cleanup and ad audiences, standardization alone gets you 90%+ recall at zero incremental cost. For anything involving physical delivery, tax filings, or compliance, spend the money on validation — the ROI is almost always positive.
How do I handle PO boxes vs street addresses?
Treat them as separate records for the same customer. A person's PO Box and their home street address are genuinely different addresses — they shouldn't collide in address dedup. But at the customer level, they can share a customer_id. Model this as: one customer, multiple addresses, one address per (customer, address_type).
What about geocoding — can I just compare lat/long?
You can, and it's brilliantly effective for some use cases. Two records within 10 meters of each other are almost certainly the same address. The catch: geocoding APIs cost money, and the accuracy at unit level (apt vs apt in the same building) is limited. Best practice is component-level matching for street addresses, geocoding for verifying and clustering points of interest.
How do I test my address standardizer?
Build a small labeled test set: 200–500 pairs of addresses tagged same/different by a human. Run your pipeline over them and measure precision (of pairs you called "same", how many actually are?) and recall (of pairs that actually are the same, how many did you catch?). Aim for >95% precision and >90% recall. Below those numbers, look at the errors — they always tell you what abbreviation or edge case your normalizer is missing.
Can I do all of this in SQL instead of Python?
Yes, for the exact-match tier and the fuzzy scoring. Trigram similarity in Postgres works well on standardized address strings. See our SQL fuzzy matching guide for the exact syntax. Parsing (libpostal) is trickier in SQL — usually you pre-parse in Python or a Cloud Function and write the parsed components back to a table, then match with SQL from there.
What if my addresses are inside long free-text fields?
libpostal handles this pretty well — feed the whole free-text blob to parse_address and it extracts the address components. If accuracy matters, a two-step approach works better: use a named-entity-recognition model to extract the address span first, then feed only the span to libpostal.
Wrapping Up
Address matching is the classic case where doing more upfront work saves an enormous amount of downstream heartache. Ten lines of regex normalization or a libpostal call in the ETL will elevate a mediocre fuzzy matcher into a great deduplicator.
Standardize first. Match components second. Fall back to fuzzy scoring only for the residuals. In that order, address dedup goes from a nightmare to a solved problem.
Related Reading
- Fuzzy Match on Multiple Columns With Weights
- Fuzzy Matching in Pandas: A Practical Guide
- Fuzzy Matching in SQL: SOUNDEX, LEVENSHTEIN & Trigrams
- The Ultimate Guide to Data Deduplication in 2026
- How to Clean Up Your Vendor Master File
Skip the regex and libpostal setup for a one-off cleanup. DedupFuzzy runs the same standardize + multi-column match pipeline in your browser and lets you weight address, name, and email independently. Free for 500 rows.
Try DedupFuzzy Free