Palindrome Checker

JJ Ben-Joseph headshot JJ Ben-Joseph

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:

clean ( s ) = reverse ( clean ( s ) )

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:

  1. Normalization: Convert all letters to lowercase so that A and a are treated the same.
  2. Filtering: Remove all characters that are not basic Latin letters a–z or digits 0–9. This matches the regular expression /[^a-z0-9]/g.
  3. Reversal: Split the cleaned string into an array of characters, reverse that array, and join it back into a second string.
  4. 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:

s [ i ] = s [ n - i - 1 ]

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:

The following comparisons illustrate how an added or changed character causes the checker’s cleaned forward and backward strings to diverge.

Sample palindromes compared with similar non-palindromes
Palindrome Non-palindrome Explanation
racecar racecars Adding an extra s at 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 odd with old changes the character sequence.
Was it a cat I saw Was it a dog I saw Replacing cat with dog alters 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:

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:

  1. Original input: "Was it a cat I saw?"
  2. Convert to lowercase: "was it a cat i saw?"
  3. Strip non-alphanumeric characters: remove spaces and the question mark. The remaining characters are:
    "wasitacatisaw"
  4. Reverse the cleaned string: reading from the end to the beginning also gives:
    "wasitacatisaw"
  5. 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?

  1. Lowercase: "was it a dog i saw?"
  2. Strip spaces and punctuation: "wasitadogisaw"
  3. Reverse: "wasigodatisaw"
  4. 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:

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:

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.

Score: 0 Timer: 30s Best: 0

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.

Result will appear here.