Palindrome Checker
Introduction: What does this palindrome checker test?
This palindrome checker tests whether the letters and digits in a word, phrase, or number match when read forward and backward. It converts text to lowercase and removes every character other than basic Latin letters and digits before reporting the result. Enter or paste text, then select the button to see the normalized text, its reversal, and the palindrome result.
Palindrome testing is performed directly in your browser, so the text entered in this checker is not sent to a server. That can be useful for wordplay, classroom examples, or notes you prefer not to upload.
What is a palindrome?
For this palindrome checker, a palindrome is a sequence of letters or digits that reads the same from left to right and right to left after irrelevant characters are excluded. The checker ignores letter case, spacing, punctuation, and other characters outside basic Latin letters and digits. For numbers, it compares the remaining digits after separators and decimal points are removed.
Examples of familiar palindromes include short words such as level and radar, along with phrases such as Never odd or even. Once spaces and punctuation are stripped and uppercase letters are treated like lowercase letters, each example has matching characters in mirror positions.
The palindrome test can be described with a cleaning function followed by an equality check between a string and its reversal. Let s be the entered text, and let clean(s) lowercase it and retain only the characters this checker analyzes.
Using mathematical notation, the entered string s passes this palindrome check when the following condition holds:
Here, reverse(x) returns the characters of a string in the opposite order. When the cleaned text and its reversed copy are identical, this checker reports the original entry as a palindrome.
How this palindrome checker works
This palindrome checker applies its character-cleaning rule before comparing your text with its reversal. The JavaScript process is:
- Normalization: Convert all letters to lowercase so that
A
anda
are treated the same. - Filtering: Remove all characters that are not basic Latin letters
a–zor digits0–9. This matches the regular expression/[^a-z0-9]/g. - Reversal: Split the cleaned string into an array of characters, reverse that array, and join it back into a second string.
- Comparison: Compare the cleaned string to its reversed version. If they are exactly equal, the input is reported as a palindrome. Otherwise it is not.
This character-by-character method keeps the palindrome result predictable, even for a long pasted passage. To determine whether a particular character affects the result, check whether it is a lowercase basic Latin letter or a digit after normalization; otherwise, the checker strips it before comparison.
Formula: Palindrome-checking time complexity and algorithmic view
For this palindrome checker, the work grows linearly with the number of characters being processed. Let n be the length of the cleaned string. Creating that string and reversing it each require work proportional to n, so the overall running time is O(n).
The same palindrome condition can be viewed as matching mirrored characters from the ends of the cleaned string toward its center. If the cleaned string is s and its length is n, every index i from 0 through n - 1 must satisfy:
A single failed mirrored match means the cleaned text is not a palindrome. Although the page’s code uses reverse-and-compare rather than pairwise comparisons, both approaches test the same symmetry.
Examples of palindromes and near-misses
Palindrome examples show how the checker handles words, phrases, and digit sequences under its normalization rule:
- Word palindromes: level, radar, civic, rotor.
- Phrase palindromes (ignoring spaces and punctuation): Never odd or even, Madam, I’m Adam, Was it a cat I saw?
- Numeric palindromes:
121,1331,12321,10101.
The following comparisons illustrate how an added or changed character causes the checker’s cleaned forward and backward strings to diverge.
| Palindrome | Non-palindrome | Explanation |
|---|---|---|
| racecar | racecars | Adding an extra sat the end breaks the symmetry. |
| Madam | Madman | Changing letters in the second half changes the reverse order. |
| 12321 | 12345 | The middle digit in the palindrome mirrors the outer pair; the second number does not. |
| Never odd or even | Never old or even | After removing spaces and case, substituting oddwith oldchanges the character sequence. |
| Was it a cat I saw | Was it a dog I saw | Replacing catwith dogalters several mirrored positions at once. |
How to interpret the palindrome checker’s results
When you submit text, the palindrome checker gives a direct result based on the normalized letters and digits it displays. Read the outcome as follows:
- Reported as a palindrome: The normalized text is exactly the same as its reversed text. Spaces, punctuation, and letter-case differences were excluded before this comparison.
- Reported as not a palindrome: The normalized text differs from its reversal at one or more character positions. One mismatch is enough to fail the palindrome test.
When an entry does not pass, use the displayed normalized and reversed strings to locate the difference. You can also reproduce the result by lowercasing the input, removing all characters except a–z and 0–9, and reading the remaining sequence from both ends.
For long text, remember that this is a character-based palindrome checker rather than a language analyzer. It does not evaluate words, grammar, or meaning; it only tests whether the retained character sequence is symmetric.
Worked example: Checking “Was it a cat I saw?”
This palindrome checker handles the phrase Was it a cat I saw?
by normalizing it before the forward-and-backward comparison.
Was it a cat I saw?
The checker performs these steps:
- Original input:
"Was it a cat I saw?" - Convert to lowercase:
"was it a cat i saw?" - Strip non-alphanumeric characters: remove spaces and the question mark. The remaining characters are:
"wasitacatisaw" - Reverse the cleaned string: reading from the end to the beginning also gives:
"wasitacatisaw" - Compare: since the cleaned string and its reverse are identical, the phrase is a palindrome under this checker’s rules.
For contrast, enter the slightly altered phrase:
Was it a dog I saw?
- Lowercase:
"was it a dog i saw?" - Strip spaces and punctuation:
"wasitadogisaw" - Reverse:
"wasigodatisaw" - Compare: the forward and reversed strings differ in multiple positions, so this version is not a palindrome.
These two phrase checks show why a small letter change can disrupt the mirrored sequence the tool examines.
Palindrome checker limitations and assumptions
This palindrome checker uses a deliberately narrow cleaning rule, so its results depend on the following assumptions about the entered text:
- Character set: Only basic Latin letters
a–zand digits0–9are taken into account. Any other characters, including accented letters, non-Latin scripts, emojis, and most symbols, are removed during the cleaning step. - Case insensitivity: Uppercase and lowercase letters are treated as the same character. For example,
A
anda
are normalized to lowercase before checking. - Spacing and punctuation: Spaces, tabs, new lines, commas, periods, question marks, and similar punctuation marks are ignored. They do not affect whether the tool considers the input a palindrome.
- Numeric formatting: Only digits matter for numbers. Characters such as commas in
1,001
or decimal points in3.33
are removed before checking. - Very long inputs: The algorithm is efficient, but extremely long entries may take noticeably longer depending on your browser and device.
- No linguistic understanding: The checker operates purely on characters. It does not understand word boundaries, grammar, or semantics, so it can label an awkward or contrived sequence as a valid palindrome.
For accented text or non-Latin writing systems such as Greek, Cyrillic, or Japanese, this checker’s current rule is not suitable because it removes those characters rather than preserving them for comparison.
How to use: Palindrome-checking use cases and audiences
This palindrome checker is useful whenever you need to test whether a sequence remains symmetrical after case, spaces, and punctuation are ignored:
- Students and teachers: Demonstrate string processing, regular expressions, and algorithmic thinking in computer science or mathematics classes.
- Puzzle fans and writers: Test candidate palindromic words, phrases, or sentences when crafting puzzles, poetry, or constrained writing pieces.
- Programmers: Quickly verify edge cases for custom palindrome functions, or check large test strings without writing additional code.
- Curious users: Experiment with names, dates, or numeric patterns to discover unexpected palindromes.
Because the palindrome test runs locally in your browser, you can paste private text without sending it over the network. The tool focuses on one transparent task: comparing the normalized character sequence with its reverse.
Arcade Mini-Game: Palindrome Checker Calibration Run
Use this quick arcade run to practice spotting the text entry needed for a palindrome check and avoiding distractions unrelated to the character comparison.
Start the game, then use your pointer or arrow keys to catch text-entry prompts and avoid unrelated items.
The checker ignores capitalization, spaces, and punctuation when evaluating.
