Introduction

Imagine searching a century-old census for your great-grandmother. You type Kowalski but the clerk wrote Kowalsky. A normal search finds nothing. Soundex finds her.

Soundex is a phonetic algorithm invented by Robert Russell and Margaret Odell around 1918 and adopted for the 1880 and 1900 US Censuses. Its idea is both ancient and elegant: instead of comparing letters, compare sounds. Strip vowels, merge similar consonants, and you get a short code — a phonetic hash — that stays the same no matter how a name is spelled, as long as it sounds the same.

The rules are surprisingly concise. Keep the first letter of the name as-is. Then scan the rest, drop vowels and the letters H, W, and Y (which rarely affect the sound), and replace consonants with digits according to a fixed table: B, F, P, V → 1; C, G, J, K, Q, S, X, Z → 2; D, T → 3; L → 4; M, N → 5; R → 6. Merge consecutive duplicates and pad or trim to exactly four characters total — one letter plus three digits.

The result: SmithS530, SmythS530. JohnsonJ525, JonsonJ525. Names that sound alike collide to the same hash; names that sound different stay apart.

Try It: Names That Sound Alike

Type any name below and watch it collapse to a four-character Soundex code. Then try a variant spelling — if the codes match, Soundex would find both in a search.

<!-- {{c_intro}} -->
<p class="hint">{{hint_para}}</p>
<div class="input-row">
  <input id="name-input" type="text" placeholder="{{input_placeholder}}" autocomplete="off" spellcheck="false" />
  <div class="code-badge" id="code-badge">----</div>
</div>
<div class="steps-box" id="steps-box"></div>
<div class="collisions-section">
  <div class="collisions-label" id="collisions-label">{{collisions_heading}}</div>
  <div class="collisions-list" id="collisions-list"></div>
</div>
<button id="reset-btn" type="button" class="ghost">{{btn_reset}}</button>
/* {{c_layout}} */
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; color: #222; margin: 0; }
.hint { font-size: .88rem; color: #444; margin: 0 0 .8rem; line-height: 1.5; }
.input-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
#name-input { flex: 1; font-size: 1.1rem; padding: .4rem .7rem; border: 1.5px solid #cdd9e3;
              border-radius: 8px; outline: none; }
#name-input:focus { border-color: #1d3557; }
.code-badge { font: 700 1.6rem ui-monospace, monospace; letter-spacing: .12em;
              background: #1d3557; color: #fff; border-radius: 10px;
              padding: .25rem .8rem; min-width: 6ch; text-align: center; }
.code-badge.match { background: #0a7d33; }
/* {{c_steps_style}} */
.steps-box { background: #f0f4f8; border-radius: 8px; padding: .55rem .75rem;
             font-size: .82rem; line-height: 1.6; margin-bottom: .7rem; min-height: 2.4rem; }
.step { margin-bottom: .1rem; }
.step .label { color: #555; }
.step .val { font-family: ui-monospace, monospace; color: #1d3557; font-weight: 600; }
/* {{c_collisions_style}} */
.collisions-section { margin-bottom: .7rem; }
.collisions-label { font-size: .82rem; font-weight: 600; color: #555; margin-bottom: .35rem; }
.collisions-list { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 2rem; }
.collision-chip { background: #e8eef3; border: 1px solid #cdd9e3; border-radius: 20px;
                  padding: .18rem .65rem; font-size: .82rem; color: #1d3557; }
.collision-chip.self { background: #1d3557; color: #fff; border-color: #1d3557; }
.collision-chip.empty { color: #888; background: transparent; border: none; font-style: italic; }
button.ghost { font: 600 13px system-ui, sans-serif; padding: .35rem .8rem;
               border: 1px solid #1d3557; background: #fff; color: #1d3557;
               border-radius: 8px; cursor: pointer; }
// Code not found

The demo computes the code in real time and shows you a handful of well-known names that share the same code, so you can see the collision in action. Notice how Robert and Rupert land on the same code, or how Katherine, Kathryn, and Katarina all collapse together — but Catherine gets a different code because Soundex always keeps the first letter.

The Real Complexity

Soundex looks trivially simple — and computationally it is. The algorithm runs in O(n)O(n) time and space in the length of the name, a single left-to-right scan. There is no clever data structure, no recursion, no backtracking.

The hard part is not computation — it is collision design.

  • Over-matching: names that sound quite different can share a code. Jackson (J250) and Jessen (J250) collide, even though no one would confuse them.
  • Under-matching: names that sound nearly identical can differ by code. Lee (L000) and Leigh (L200) do not match because the silent gh adds an R-equivalent code position.
  • Language bias: Soundex was built for English-language transcriptions of mostly European surnames. It performs poorly on names from Arabic, Chinese, Hebrew, or many African languages, where the phonetic rules simply do not apply.

These limitations motivated a chain of successors. Metaphone (Lawrence Philips, 1990) handles more English phonetic rules. Double Metaphone (Philips, 2000) adds a second code for ambiguous pronunciations and covers more language families. NYSIIS (New York State Identification and Intelligence System) targets a different trade-off. Caverphone was designed specifically for New Zealand census names.

Each algorithm is essentially a hand-coded compression of a language's phonology: a function from strings to a smaller alphabet where phonetically close strings hash nearby. None of them solves the general problem — that would require a full model of pronunciation, which brings you into the territory of string algorithms and even speech recognition.

The deeper insight is that Soundex encodes a many-to-one mapping: many strings collapse to one code. This is the same idea as a hash function, but optimized for human sound perception rather than uniform distribution.

Where It Matters

Phonetic matching is one of the oldest and most widely deployed tricks in data management:

  • Genealogy and ancestry search: sites like Ancestry.com and FamilySearch index hundreds of millions of historical records with Soundex so that a spelling variant never hides a relative.
  • Voter registration and deduplication: election authorities use phonetic codes to flag likely duplicate registrations when names are entered with different spellings across records.
  • Medical record linkage: hospitals match patients across admissions even when a name is misspelled, transliterated, or hyphenated differently — a patient safety issue that phonetic hashing partially addresses.
  • Spell-checking and autocorrect: early spell-checkers used phonetic distance to suggest corrections; modern systems layer phonetic similarity on top of edit distance for better suggestions.
  • Search engines and databases: SQL databases expose SOUNDEX() as a built-in function; full-text search engines use phonetic variants as query expansion.

Whenever human names travel through systems — typed by hand, transcribed from speech, translated between alphabets — phonetic matching is the first line of defense against the chaos of spelling variation.

Conclusion

Soundex is over a century old and still embedded in nearly every major database engine. Its power comes not from computational sophistication — the algorithm is four rules and a lookup table — but from a conceptual insight: compress by sound, not by spelling.

That compression is lossy by design. The collisions are a feature, not a bug: you want Smith and Smyth to land in the same bucket. But every lossy compression trades precision for recall, and Soundex makes that trade aggressively. Its successors — Metaphone, Double Metaphone, NYSIIS — all try to find a better point on that curve.

The next time a search engine finds your ancestor under a spelling you never tried, a tiny four-character code from 1918 quietly did its job — reminding us that sometimes the oldest algorithms are the most durable ones.

Share this article

Pick a channel — or use your device's native share sheet.

Comments

Loading comments...

https://www.kipuhub.com/en/article/soundex-phonetic/Content licensed under CC BY-NC 4.0.