Solved.tools โ€” Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Anagram Checker

Last updated: 16 August 2026

Reviewed by Gavin ยท Research and drafting assisted by AI

6 chars
swap
6 chars
โœ…
โ€œlistenโ€ and โ€œsilentโ€ ARE anagrams.
Normalized: listen = silent (6 chars)
A โ†’ sorted
eilnst
B โ†’ sorted
eilnst
Word A
e
1
i
1
l
1
n
1
s
1
t
1
Word B
e
1
i
1
l
1
n
1
s
1
t
1
Green bar = counts match on both sides. Red bar = counts differ. Grey = letter absent from this side.
Was this helpful?


Anagram Checker

An anagram is a word or phrase formed by rearranging the letters of another word or phrase, every original letter is used exactly once and no letters are added or dropped. The classic examples are short and instantly recognisable: listen โ†” silent, debit card โ†” bad credit, astronomer โ†” moon starer. Longer phrases work the same way once you strip the spaces and ignore capitalisation: I am Lord Voldemort contains exactly the same letters as Tom Marvolo Riddle, which is why the reveal works in J. K. Rowling's Harry Potter and the Chamber of Secrets. This tool checks two strings against each other and tells you, in real time, whether they are anagrams of one another, where their letter multisets match and where they differ, and what both strings look like after normalisation.

The word anagram itself comes from the Greek anagrammatismos, meaning "rearrangement of letters", which in turn combines ana- ("again") and gramma ("letter"). It passed through Latin anagramma and French anagramme before entering English in the late 16th century. The Oxford English Dictionary's earliest English citation is from 1589. Lewis Carroll, author of Alice's Adventures in Wonderland and Through the Looking-Glass, was an enthusiastic anagrammatist and regularly built his own pen-name puzzles by rearranging real names; T. S. Eliot used anagrams in his poetry, and the device appears across centuries of wordplay, from the court poets of the Renaissance to modern crossword constructors.

How to use this anagram checker

  1. Paste or type the first word or phrase into the Word A box on the left.
  2. Paste or type the second word or phrase into the Word B box on the right.
  3. Toggle Ignore case on if you want "Hello" and "hello" to compare as equal (default ON).
  4. Toggle Ignore whitespace & punctuation on if you want phrase-level anagrams like "debit card" โ†” "bad credit" to register as anagrams (default ON).
  5. Read the green โœ… or red โŒ banner. The banner shows the normalised form of both sides so you can see exactly why the tool reached its verdict.
  6. Scroll down to the side-by-side letter histograms to see at a glance which letters each side contributes and which letters differ.
  7. Use the โ‡„ swap button if you pasted into the wrong boxes, and the ๐Ÿ“‹ Copy result button if you want to paste the verdict into a chat or document.
  8. Click any of the six famous examples under Try a famous example to instantly load a known anagram pair.

The algorithm

This checker uses the standard sort-and-compare algorithm: normalise both inputs, sort the letters, and compare. Normalisation means lowercasing (when the case-insensitive toggle is on) and stripping non-alphanumeric characters (when the whitespace-and-punctuation toggle is on). Once both inputs are in their canonical form, sorting the characters of each string produces a canonical fingerprint. If the two fingerprints are identical, the original strings are anagrams; otherwise they are not.

The procedure in detail:

  1. Normalise input A: lowercase it, then remove every character that is not a letter or a digit. Store the result as normA.
  2. Normalise input B: lowercase it, then remove every character that is not a letter or a digit. Store the result as normB.
  3. Length check: if normA.length !== normB.length, the inputs cannot be anagrams, return false immediately. This is the only short-circuit the algorithm has.
  4. Sort: convert each normalised string into an array of characters, sort using the standard Unicode codepoint order, join back into a string. Store as sortedA and sortedB.
  5. Compare: if sortedA === sortedB, the inputs are anagrams (true). Otherwise they are not (false).

The algorithm runs in O(n log n) time, where n is the length of the longer normalised string, dominated by the sort. The auxiliary memory is also O(n) because each normalised and sorted string is stored separately. For phrases of any realistic length, even the full 24 characters of Tom Marvolo Riddle, this is well under a microsecond in JavaScript on a modern browser. An alternative O(n) algorithm exists (count the frequency of each character, compare the two frequency maps), but the sort-and-compare approach is shorter to implement, easier to explain, and fast enough for any human-typed input.

Empty inputs are not anagrams by convention, comparing two empty strings is a degenerate edge case that most users don't mean when they ask the question, so this checker returns false when either input is empty after trimming.

Worked examples

Example 1: "listen" vs "silent", both 6 letters. Normalised, both are already lowercase alphabetic strings, so they survive normalisation unchanged. Sorting each yields eilnst and eilnst. The sorted strings are identical, so the verdict is anagrams โœ…. The histograms are identical too: one each of e, i, l, n, s, t.

Example 2: "I am Lord Voldemort" vs "Tom Marvolo Riddle", 24 characters each (including spaces), but after stripping spaces we get iamlordvoldemort and tommervoloriddle. Both contain exactly: a, d, d, e, i, l, l, m, m, o, o, o, r, r, r, t, v (twice the d), and one of each of the other letters. Sorted, both produce the same 24-character string. The verdict is anagrams โœ….

Example 3: "debit card" vs "bad credit", after stripping spaces and lowercasing: debitcard and badcredit. Both contain a, a, b, c, d, d, e, i, r, t, sorted, both equal aabcddeirt. Verdict: anagrams โœ…. (Note that Tom Marvolo Riddle contains 24 letters and debit card contains 9; the algorithm works the same way regardless of length.)

Example 4: "Astronomer" vs "Moon starer", after stripping the space and lowercasing: astronomer and moonstarer. Both contain the same letter multiset: a, e, m, n, o, o, o, r, r, r, s (11 letters). Sorted, both equal aemnooorrrs. Verdict: anagrams โœ….

Example 5: "hello" vs "world", after lowercasing: hello and world. hello has h, e, l, l, o; world has w, o, r, l, d. Even though both contain an l and an o, the rest of the letters don't match (h vs w, e vs r, l vs d). Sorted, hello is ehllo and world is dlrow. The sorted strings differ, so the verdict is not anagrams โŒ. The histograms show where: hello has no w, r, or d; world has no h or e.

These five examples cover the three outcomes the tool can produce (anagrams, not anagrams, and the empty-input edge case), exercise phrase-level inputs with whitespace, and include both pure-ASCII and capitalised inputs.

Where anagram checking shows up

Cryptograms and substitution ciphers. Most newspaper cryptograms are simple substitution ciphers, but anagram-style transposition ciphers have been used historically (the scytale of ancient Sparta is a famous example). Modern software for solving them uses anagram checking as a primitive for candidate enumeration.

Crosswords, Scrabble, and word puzzles. When a Scrabble player sees seven tiles and wants to know whether any dictionary word is an anagram of those letters, the engine builds a sorted-letter signature for every word in the word list and looks up the signature of the rack. Anagram indexing is the technique, and it reduces a seven-letter search to a single hash-table lookup. The same trick powers most crossword helpers and "jumble" puzzle solvers.

DNA and protein sequence comparison. In bioinformatics, two DNA sequences that contain the same nucleotide multiset (the same counts of A, T, C, G) but in a different order are sometimes called anagrams of each other. Sequence-assembly tools use this property to detect fragments that come from the same region. The technique extends to amino-acid sequences for protein comparison, where an "anagram" check is a cheap way to discard candidates before running a heavier alignment.

Software engineering interviews and competitive programming. The "anagram detection problem" is a classic interview warm-up question and the first problem on many algorithm textbooks' strings chapter. The standard expected solution is the sort-and-compare approach used here, with the optimal follow-up being the O(n) frequency-count solution. Both are part of the standard software-engineering canon.

Plagiarism detection and stylometry. Authorship attribution sometimes asks whether two passages contain the same letter frequencies, which is the same computation as an anagram check on the letter histogram. Distant cousins of the algorithm power tools that flag suspiciously similar texts.

Word games, geocaches, and escape rooms. Many physical puzzle boxes and treasure-hunt caches use anagram-style clues ("the answer is an anagram of silent listen"). An instant checker is genuinely useful when the puzzle has you stuck.

Common mistakes

Forgetting case. "Hello" and "hello" are not the same string to a strict character-by-character comparison, but they obviously contain the same letters. Always turn the case-insensitive toggle on (it is on by default) when comparing real words.

Forgetting whitespace. "debit card" and "debitcard" differ by one space. With the whitespace-and-punctuation toggle off, the checker reports them as not anagrams. With it on, they collapse to the same canonical string. Decide which behaviour you want and keep it consistent.

Comparing Unicode characters naively. JavaScript string comparison is codepoint-by-codepoint, so "rรฉsumรฉ" and "resume" are different strings even though a human reader considers them equivalent. This checker treats each character as itself, it does not decompose accented characters. If you need Unicode-aware normalisation, paste the strings through a Unicode-normalisation tool first.

Comparing anagrams and palindromes. A palindrome reads the same forwards and backwards ("racecar"); an anagram rearranges letters into a different word ("listen" โ†’ "silent"). The two properties are independent, "racecar" is its own palindrome but has no common anagram partner of the same length, and "listen" is not a palindrome but trivially anagrams to "silent". Don't conflate the two.

Empty strings. Two empty strings are technically anagrams under the strict mathematical definition (both have a length-0 letter multiset), but the more useful interpretation is that the user hasn't typed anything yet. This checker returns false in the empty-input case so the result is meaningful: it tells you "these two non-empty strings do or don't rearrange into each other".

Reversed vs rearranged. "hello" reversed is "olleh", but reversing is not the same as rearranging, an anagram check accepts "olleh" only if "hello" happens to contain those letters in exactly those counts. The reverse of "hello" happens to fail its own anagram test against "hello" because the letter counts differ (one l in "olleh" vs two l's in "hello").

Frequently Asked Questions

What counts as an anagram? Strictly, an anagram is a rearrangement of the letters of one word or phrase into another, using every letter exactly once and without adding or dropping anything. The two phrases must contain the same letter multiset, same count of each letter, for them to be anagrams. "listen" and "silent" qualify; "listen" and "listening" do not (one has seven letters and the other has nine).

Do spaces and punctuation matter? By default this checker ignores them (the toggle is on). For most wordplay purposes, including spaces would make phrase-level anagrams impossible to detect: "debit card" and "bad credit" are anagrams in the colloquial sense, but they only become so once you strip the inner space. If you want strict character-level comparison, turn the toggle off.

Is "I am Lord Voldemort" really an anagram of "Tom Marvolo Riddle"? Yes. Both phrases contain exactly the same 24 letters: one a, two ds, one e, one i, two ls, two ms, three os, three rs, one t, and one v. The checker will confirm this if you paste both phrases in. (The original Rowling text uses the same trick in Chamber of Secrets.)

What is the difference between an anagram and a palindrome? A palindrome is a string that reads the same forwards and backwards, its mirror image is itself. An anagram is a string that contains the same letters as another string but in a (potentially) different order. "racecar" is a palindrome but not an anagram of any other common English word. "listen" and "silent" are anagrams of each other but neither is a palindrome. The two properties are independent.

Does case matter? Only when you turn the case-insensitive toggle off. The default is on (ignore case), which is the right choice for almost all wordplay. "Hello" and "HELLO" are anagrams when the toggle is on and are not anagrams when it is off.

What about accents and Unicode? This checker treats each Unicode codepoint as its own character. "rรฉsumรฉ" and "resume" will not be reported as anagrams because the first contains two รฉs (each a single codepoint) and the second does not. If you need strict Unicode-equivalence checking, run both inputs through a Unicode normaliser (such as NFKD decomposition) before pasting them in.

Can two strings of different lengths be anagrams? No. If the normalised forms differ in length, the letters cannot be the same on both sides. The checker short-circuits and reports false as soon as it sees a length mismatch. This is by far the cheapest check and saves the sort step on obviously-mismatched inputs.

Is this checker free to use? Yes. The tool runs entirely in your browser, no data leaves your device. Paste any two strings, toggle the options you want, and read the result. There is no signup, no rate limit, and no tracking.

What algorithm does the checker use? The sort-and-compare algorithm: normalise both inputs (lowercase + drop non-alphanumeric if those toggles are on), sort the remaining letters, compare. It runs in O(n log n) time where n is the length of the longer normalised string. The alternative frequency-counting algorithm runs in O(n) but is more code; for human-typed phrases the difference is unnoticeable.

Can I use this in my own code? Yes, the algorithm is a textbook example and the implementation is short. The normalisation step is s.toLowerCase().replace(/[^a-z0-9]/g, ''), the sorting step is [...s].sort().join(''), and the comparison step is sortedA === sortedB. Wrap the three steps in a function and you have a reusable anagram check.

References

  • Oxford English Dictionary, anagram, n.: etymological note and earliest English citation (1589). Oxford University Press.
  • Lewis Carroll (Charles Lutwidge Dodgson), The Hunting of the Snark and miscellaneous anagram puzzles; Oxford, 1876.
  • T. S. Eliot, The Waste Land (1922) and later poems, for the use of anagram and letter-rearrangement as a poetic device.
  • Wikipedia contributors, Anagram (encyclopaedia overview of etymology, history, and computational approaches).
  • Cormen, T. H., Leiserson, C. E., Rivest, R. L., Stein, C., Introduction to Algorithms (3rd ed.), MIT Press, for the sort-and-compare pattern and frequency-counting alternative in the strings chapter.
  • Rowling, J. K., Harry Potter and the Chamber of Secrets (1998), for the Tom Marvolo Riddle / I am Lord Voldemort anagram reveal.