Anagram Checker

Check if two words are anagrams of each other and rearrange letters

What is it and how does it work?

An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all original letters exactly once. "Listen" is an anagram of "Silent". "Astronomer" rearranges to "Moon starer". "Dormitory" → "Dirty room". The study of anagrams dates back to ancient Greece — Pythagoras and his followers believed hidden meaning could be found by rearranging letters. Anagrams became popular in medieval literature and persist today in puzzles, cryptic crosswords, and creative wordplay.

This tool checks whether two words or phrases are anagrams of each other, generates anagrams from a given word (looking up real words), and finds anagram sets within a word list. The check works by normalizing both strings (lowercasing, removing spaces and punctuation), then sorting the characters alphabetically — two strings are anagrams if and only if their sorted character arrays are identical.

Common use cases

Frequently asked questions

What is the fastest algorithm to check if two strings are anagrams?

Method 1 (sort): sort both strings alphabetically and compare — O(n log n). `"listen".split("").sort().join("") === "silent".split("").sort().join("")`. Method 2 (frequency count): count character frequencies in both strings and compare counts — O(n), optimal. Create a Map from string A, increment for A's chars, decrement for B's chars — if all values are 0, they're anagrams. Method 2 is faster for large strings but Method 1 is simpler to implement.

Do spaces and punctuation count in anagrams?

For phrase anagrams, convention usually ignores spaces and sometimes punctuation. "The eyes" → "They see" (spaces ignored). "Madam Curie" → "Radium came" (spaces ignored). For strict anagram checks (character-level), spaces count. This tool offers both modes — character-for-character matching or space/punctuation-normalized matching.

What are the longest known English anagram pairs?

Some notable long anagram pairs: "astronomer" / "moon starer" (10 letters), "conversation" / "voices rant on" (12 letters), "the Morse Code" / "here come dots" (13 chars including spaces), "dormitory" / "dirty room" (9 letters). "The eyes" / "they see" is a commonly cited perfect phrase anagram (7 letters plus spaces). Professional anagrammers work with much longer texts.

What is an anagram in programming and data structures?

Checking for anagrams is a classic interview question. It tests: string manipulation, hash maps/frequency arrays, understanding of character encoding. The frequency-count approach generalizes to "group anagrams together": given `["eat","tea","tan","ate","nat","bat"]`, group anagrams by sorting each word and using sorted word as key → `{"aet": ["eat","tea","ate"], "ant": ["tan","nat"], "abt": ["bat"]}`. This is LeetCode problem 49.

Text

Uppercase / Lowercase · Word Counter · Character Counter · Lorem Ipsum Generator · Remove Extra Spaces · Sort Text Lines