Skip to content
πŸ› οΈToolsShed

Palindrome Checker

Check if a word, phrase, or number reads the same forwards and backwards.

About this tool

A palindrome is a word, phrase, or number that reads exactly the same forwards and backwards. This tool instantly checks whether your input is a palindrome by comparing its characters in both directions. Whether you're checking classic palindromes like "racecar" or "madam," verifying numerical palindromes, or exploring phrases that read the same way reversed, this checker handles the work for you.

Simply type or paste your text into the input field and the tool will immediately tell you whether it's a palindrome. The checker ignores spaces and punctuation by default, focusing only on letters and numbers, which means you can test full sentences like "A man a plan a canal Panama" without worrying about formatting. This makes it perfect for word games, puzzles, creative writing projects, or simply satisfying your curiosity about word patterns.

Frequently Asked Questions

Code Implementation

import re

def is_palindrome(text: str, ignore_case=True, ignore_spaces=True) -> bool:
    """Check if a string is a palindrome."""
    cleaned = text
    if ignore_spaces:
        # Remove all non-alphanumeric characters
        cleaned = re.sub(r'[^a-zA-Z0-9]', '', cleaned)
    if ignore_case:
        cleaned = cleaned.lower()
    return cleaned == cleaned[::-1]

# Examples
print(is_palindrome("racecar"))        # True
print(is_palindrome("Hello"))          # False
print(is_palindrome("A man a plan a canal Panama"))  # True
print(is_palindrome("Never odd or even"))            # True
print(is_palindrome("12321"))          # True
print(is_palindrome("Was it a car or a cat I saw"))  # True

# Find all palindromic words in a sentence
def find_palindromes(sentence: str):
    words = sentence.lower().split()
    return [w for w in words if len(w) > 1 and w == w[::-1]]

print(find_palindromes("The racecar level went noon to noon"))
# ['racecar', 'level', 'noon', 'noon']

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.