How Anagram Solvers Work
"Anagram solver" covers at least three genuinely different problems, and conflating them leads to the wrong algorithm. Checking whether two specific words are anagrams of each other is one problem. Finding every dictionary word that fits inside a rack of letters — using some or all of them — is a second, harder problem. Matching a pattern like "c?t" or "st*ing" against the whole dictionary is a third, different problem again. This guide walks through the real technique behind each one, using this site's own solver code (in src/solver/core/) as the worked example throughout, rather than a generic textbook description.
Problem 1: are two words exact anagrams?
This is the simplest case, and the fastest correct technique is a sorted-letter signature: take a word's letters, sort them alphabetically, and join them back into a string. "LISTEN" and "SILENT" both sort down to "EILNST" — same signature, so they're anagrams. Two words are anagrams of each other if and only if their signatures are identical, because sorting removes order while preserving exactly which letters, and how many of each, the word contains. This site's signatureOf() function (in src/solver/core/derive.ts) does exactly this, and it's the technique behind both the anagram checker tool and the anagram-set groupings used throughout words with the most anagrams — finding every word sharing a signature across the whole 175,053-word list is just a matter of computing every word's signature once and grouping identical ones together.
The anagram checker tool actually goes one step further than a bare signature match, because it also needs to explain why two words aren't anagrams when they aren't. Its real comparison (compareAnagram() in src/solver/core/compare.ts) builds a 26-slot count vector for each word — one slot per letter, holding how many times that letter appears — then compares the two vectors slot by slot. If every slot matches, the words are anagrams; if not, the tool reports exactly which letters are over- or under-represented on which side ("the first has 2 more 'E' than the second"), which a bare signature match can confirm but can't explain on its own.
Problem 2: which dictionary words fit inside a rack?
This is the homepage tool's job, and it's a fundamentally different question from problem 1: instead of comparing two fixed words, it has to test a candidate word against a rack for every word in the dictionary, fast enough to respond instantly. Checking every one of 175,053 words digit-by-digit against the rack on every single search would work, but it's wasteful — most words can be eliminated almost immediately. This site's real implementation (solveSubset() in src/solver/core/solve.ts) uses a two-stage filter to avoid that waste:
- A 26-bit mask prefilter. Every word in the index has a precomputed bitmask marking which of the 26 letters it contains at all (ignoring how many times). The rack gets the same treatment. Any word whose mask has a bit set that the rack's mask doesn't — meaning the word needs a letter the rack doesn't have even once — is eliminated in a single bitwise AND, with no need to examine individual letter counts yet.
- A 26-slot count-vector check, only for words that survive the mask filter. For the words that pass stage one, the solver compares full letter counts (how many E's, how many S's, and so on) against the rack's counts, to catch the cases a bare "does it contain this letter at all" mask can't: a word needing two E's when the rack only has one would pass the mask test (the rack does contain an E) but correctly fails the count test.
This two-stage approach is exactly why the real homepage tool can search the full word list and respond in single-digit milliseconds even for a worst-case 13-letter rack with 2 blanks (measured at 21.1 ms p95 during this site's own performance testing) — the bitmask stage eliminates the overwhelming majority of the dictionary almost for free, leaving only a small number of genuinely plausible candidates for the more detailed count check.
Problem 3: matching a letter pattern, not a rack
The word finder tool (pattern mode: "c?t", "st*ing") is solving neither of the problems above — there's no rack of specific letters to contain, just a shape to match. This site's real approach (solvePattern() in src/solver/core/modes.ts) compiles the pattern directly into a regular expression (? becomes a single-character wildcard, * becomes a run of any length) and tests it against every candidate word of a compatible length. This works well specifically because the regex only has to run against words of the right length rather than the entire dictionary — words are pre-grouped by length in the index, so a 4-letter pattern never gets compared against a 9-letter word in the first place.
Why not a trie?
A trie (a tree where each node represents one letter, and a path from the root spells out a word) is a genuinely good structure for some dictionary problems — prefix search ("every word starting with 'un-'") and certain pattern-matching schemes can be very efficient on a trie, because shared prefixes are stored once and a search can abandon a branch the moment it no longer matches. But a trie is built around letter order, and anagram and rack solving are specifically about matching letters regardless of order — the entire point of a signature or a count vector is to throw order away. Forcing that kind of matching onto a trie means either trying every possible letter ordering of the rack against the tree (expensive) or building extra machinery on top of the trie to simulate what a count vector already does for free. For the specific problems this site's tools solve, a sorted signature and a count vector, backed by a bitmask prefilter, are a better fit than a trie would be — which is also simply a reflection of the real code: there is no trie anywhere in this site's solver, by design, not by oversight.
A detail that might be surprising: "exact" mode isn't a separate algorithm
This site's anagram solver actually runs two different modes behind one input box: "exact" (every tile must be used, the classic anagram-solving question) and "subset" (any number of the rack's letters, the homepage's default). It would be reasonable to assume exact mode needs its own, simpler algorithm — after all, matching the entire rack sounds like it should reduce cleanly to the sorted-signature technique from Problem 1. But this site's real implementation (solveExact() in src/solver/core/modes.ts) doesn't do that at all: it's a one-line wrapper that calls the same solveSubset() function used for the rack/subset problem, just with the minimum and maximum word length both pinned to the rack's full letter count. Exact-anagram matching, in other words, is just subset matching with the search space narrowed to exactly one length — the mask-and-count-vector machinery handles both cases without needing two separate code paths, because "use every tile" is simply the most restrictive case of "use some subset of tiles."
How blank tiles fit into the subset algorithm
Blank tiles (entered as a "?") add a real wrinkle to the subset algorithm described above: a blank can stand in for any single letter, so the solver can't just check whether the rack directly contains everything a candidate word needs. This site's implementation handles it as a deficit count: during the same prefilter pass described earlier, for each letter the candidate word needs more of than the rack actually has, the shortfall gets added to a running "deficit" total; if that total ever exceeds the number of blanks available, the word is rejected on the spot. A word that needs one more "Q" than the rack has, with one blank available, passes; a word needing two more letters than the rack has, with only one blank, does not.
Figuring out which letters the blanks actually stood for, once a word is accepted, is handled as a separate, deliberately lazy step: rather than computing that mapping for every word that merely passes the deficit check, this site's solver only works it out for words that actually survive the response-limit cutoff and get sent back to the caller (via a small helper that walks the matched word's letters, consuming rack letters first and recording whatever's left over as blank-supplied). This matters at scale, because it means the expensive "which blank stood for which letter" bookkeeping never runs for the thousands of candidate words that get filtered out before the limit — only for however many actually make it into the response.
Ordering and tie-breaking, once candidates are found
Finding the matching words is only half the job — the real tool also has to decide what order to show them in. This site's own collectGroups() (in src/solver/core/collect.ts) orders results by length, longest first, and within a length, puts common-tier words ahead of rarer ones, alphabetically within each group. That ordering is a deliberate choice about what's most useful to see first (a long, familiar word is usually a more satisfying answer than a short, obscure one), not an inherent property of the underlying algorithm — a different tool solving the identical search problem could reasonably choose to sort differently.
What this means if you're building your own
If you're implementing something similar yourself — see build a word unscrambler in JavaScript for a full walkthrough — the practical takeaway is to match the technique to the actual question being asked rather than reaching for one generic "anagram algorithm" everywhere. Exact-anagram comparisons want a signature or count vector; rack/subset searches want a count vector with a cheap prefilter in front of it to avoid wasted work at scale; pattern matching wants length-bucketed candidates tested against a compiled pattern. Mixing these up — say, using a full dictionary scan for every rack query with no prefilter — is the most common reason a hand-built solver that works fine on a small word list slows down badly once it's pointed at a real, full-sized dictionary like this site's 175,053 entries.
Related reading
For the actual counts these techniques are run against, see words with the most anagrams and letter frequency in English words. For a hands-on implementation walkthrough using these same ideas, see build a word unscrambler in JavaScript. To try the actual tools described here, see the anagram solver, word finder and anagram checker.