Credit Card Validator
A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call
Free credit card validator. Check a card number's format with the Luhn algorithm and identify Visa, Mastercard, Amex and more. Runs only in your browser.
- Card type
- 0
- Length
- 0
- Correct check digit
- 0
- Masked
- 0
Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.
How to use the credit card validator
- Type or paste a card number. Spaces and dashes are fine.
- Read the result. The credit card validator shows whether the number passes the Luhn checksum, the card type (Visa, Mastercard, American Express, Discover, JCB, Diners Club, UnionPay or Maestro), whether the length is normal for that type, the correct check digit, and a masked version of the number.
The check happens entirely in your browser. The number is never sent anywhere, saved or logged.
What this tool checks, and what it doesn't
The credit card validator checks whether a number is correctly formed: the right length, a recognised prefix, and a valid check digit. It catches typing mistakes.
It does not check whether a card exists, is active, belongs to anyone, or has money available. Only the card issuer, through a payment processor, can do that. A number can pass the Luhn check and still be fake, expired or cancelled.
That makes the tool useful for:
- Developers and testers building checkout forms and checking test card numbers.
- Shops and support teams spotting a mistyped number before trying a payment.
- Students learning how checksums work.
How the Luhn algorithm works
Almost every payment card number ends with a check digit calculated with the Luhn algorithm (also called mod 10), invented by IBM scientist Hans Peter Luhn in the 1950s.
To check a number:
- Starting from the right, double every second digit (the second from the right, the fourth, and so on).
- If doubling gives a number over 9, subtract 9 (or add its two digits together).
- Add up all the digits.
- If the total ends in 0 (is divisible by 10), the number is valid.
For the standard test number 4111 1111 1111 1111, the total is 30, which is divisible by 10, so it passes.
The Luhn check catches every single mistyped digit and most cases of two neighbouring digits swapped. It isn't a security feature; it's an error-catching feature.
Finding the correct check digit
If a number fails, the credit card validator shows what the last digit would need to be. For 4111 1111 1111 1121, the check digit should be 9, not 1. If the rest of the number is right, the last digit was mistyped; if not, another digit is wrong somewhere, and the customer should check the card again.
Card types by number
The first digits of a card number (the issuer identification number, IIN, or bank identification number, BIN) show the network:
- Visa: starts with 4. Usually 16 digits (also 13 or 19).
- Mastercard: starts with 51 to 55, or 2221 to 2720. 16 digits.
- American Express: starts with 34 or 37. 15 digits.
- Discover: starts with 6011, 644 to 649, or 65 (and some 622 ranges). 16 to 19 digits.
- JCB: starts with 3528 to 3589. 16 to 19 digits.
- Diners Club: starts with 36, 38, 39 or 300 to 305. 14 to 19 digits.
- UnionPay: starts with 62. 16 to 19 digits.
- Maestro: various prefixes such as 5018, 5020, 5038, 6304 and 6759. 12 to 19 digits.
The credit card validator uses these ranges and checks that the length is normal for the network. Card networks occasionally add new ranges, so very new cards might show as "unknown" even when valid.
Test card numbers
Payment providers publish test numbers that pass the Luhn check but never charge real money, such as 4111 1111 1111 1111 (Visa) and 5555 5555 5555 4444 (Mastercard). Use your payment provider's test numbers in development and sandbox environments, never real cards.
Building card validation into a form
If you're a developer:
- Validate as the user types: detect the card type from the first digits to show the right logo and format the number in groups.
- Run the Luhn check before submitting, to catch typos instantly.
- Never store full card numbers yourself unless you're PCI DSS compliant. Use your payment provider's hosted fields or tokens, so raw numbers never touch your servers.
- Mask numbers in any display or log: show only the last four digits.
For other checks in forms, the email validator and the IBAN validator work the same way. To test patterns, the regex tester helps.
Keeping card data safe
- Don't paste real card numbers into tools that send data to a server.
- Don't send card numbers by email or chat.
- Be wary of anyone asking for a card number, expiry date and security code outside a secure checkout.
Privacy and accuracy
Card numbers stay in your browser. Nothing is uploaded, stored or logged, and the page doesn't need a network connection to check a number. The credit card validator applies the Luhn algorithm exactly and matches published network prefixes, with no AI involved. It only checks the format of a number, never whether a card is real or usable.
Other numbers that use the Luhn check
The same mod 10 algorithm protects many identification numbers besides payment cards:
- IMEI numbers on mobile phones.
- Some national identification numbers, such as Canadian Social Insurance Numbers.
- Some loyalty, gift card and account numbers.
The credit card validator applies the Luhn check to any 12 to 19-digit number, though the card-type detection only applies to payment cards.
Why some numbers fail
A number fails the Luhn check if any digit is wrong, digits are missing or extra, or two neighbouring digits are swapped (except 09 and 90). If a customer's number keeps failing, check the length first: Amex cards have 15 digits, most others 16. Then read the number back in groups of four.
Expiry dates and security codes
The credit card validator only checks the card number. The expiry date and the security code (CVV or CVC) are checked by the card issuer during payment. Never ask customers to send these by email, chat or messaging apps, and never store security codes after authorisation, which payment card rules forbid.
Quick reference
- PAN: primary account number, the card number.
- IIN / BIN: the first six to eight digits, which identify the issuer.
- Check digit: the last digit, set by the Luhn algorithm.
- Luhn (mod 10): the checksum that catches typing mistakes.
- Masking: showing only some digits, such as the last four.
How card numbers are structured
A payment card number has three parts. The first six to eight digits are the issuer identification number, which tells the network (Visa, Mastercard and so on) and the bank that issued the card. The middle digits identify the individual account. The last digit is the Luhn check digit. That's why the credit card validator can name the network from the first digits and catch typing mistakes from the last, without ever contacting a bank. The account number itself is private to the issuer, and only the issuer can confirm whether the card is active.
For developers testing forms
Use the credit card validator to check that your form's own validation agrees: test numbers that should pass, numbers with one wrong digit, and numbers of the wrong length. Matching results give confidence that customers won't be blocked by a buggy check.
A worked example
A support agent at an online shop takes a phone order. The customer reads out 4111 1111 1111 1121. Before trying the payment, the agent enters it into the credit card validator: it's recognised as a Visa, 16 digits, but it fails the Luhn check. The correct check digit would be 9.
The agent asks the customer to read the number again. The customer had misread one digit: the correct number passes the check. The payment goes through first time, without a declined transaction on the customer's card.
Need more customers from Google?
This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit is a Google Ads agency that does PPC and nothing else: we build the campaigns, block the searches that waste money, write the ads, set up conversion tracking and send you a short report every week. Request a free PPC audit and we will show you, in dollars, what we would fix first.
Frequently asked questions
How do I check if a credit card number is valid?
Enter it in the credit card validator. It checks the Luhn checksum, the card type and the length.
Does passing the check mean the card is real?
No. It only means the number is correctly formed. Only the issuer can confirm a card exists and works.
What is the Luhn algorithm?
A checksum formula that catches typing mistakes in card numbers and other identification numbers.
How can I tell the card type from the number?
From the first digits: Visa starts with 4, Mastercard with 51 to 55 or 2221 to 2720, Amex with 34 or 37.
Is it safe to enter a card number here?
The check happens only in your browser and nothing is sent or stored. For real cards, it's still good practice to use test numbers where possible.
Is the credit card validator free?
Yes, completely free, with no sign-up.
Free PPC audit
See where your ad budget leaks.
We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.