Card Number Format Check (Luhn)
For developers testing payment forms: check that a card number is well formed, with a matching Luhn check digit and a length that fits its network. It does not check CVV, expiry or whether a card exists.
Test numbers from Stripe's testing documentation. This checks format only, not whether a card is active or has funds.
How the format check works
This check uses the Luhn algorithm (also called the mod-10 algorithm) to test whether a card number's last digit matches the rest, the same first-pass check payment forms use to catch a mistyped number before a payment is attempted.
- 01Starting from the rightmost digit, double every second digit
- 02If doubling results in a number greater than 9, subtract 9
- 03Sum all the digits together
- 04If the total is divisible by 10, the card number is valid
- Card number length (13 to 19 digits)
- Luhn algorithm checksum
- The network from the prefix, and whether the length fits that network
- Does NOT check if card is active or has funds
- Does NOT verify expiration date or CVV
Worked example: is 4539 1488 0343 6467 valid? Starting from the right, double every second digit (the 6 in the second-from-last position becomes 12, and so on), subtract 9 from any result above 9, then add every digit together. For this number the total comes to a multiple of 10, so it passes. Flip just the last digit (4539 1488 0343 6468) and the total no longer divides by 10, so it fails. That single check digit is what catches most mistyped card numbers.
Card number format by network
The first few digits, the Issuer Identification Number (IIN, also called the BIN), tell you which network issued the card, and each network issues numbers of set lengths. The validator names the network from the prefix and checks the length against this table:
The final digit of every card is the Luhn check digit, calculated from the rest of the number.
What the transfer costs
A card number passing the Luhn check says nothing about what paying by card costs. Money transfer services can price paying by card differently from paying from a bank account, and the Western Union calculator shows its price for each way of paying at your amount.
See the full breakdown by payment method on the Western Union fee calculator, or compare providers on the money transfer hub. Your card issuer may treat a money transfer as a cash advance, with its own fee and interest; its card terms say.
Frequently Asked Questions
Should I enter my real credit card number here?
No. The check runs in your browser and our code does not send the number anywhere, but a format check never needs a real card: use the test numbers above instead. This tool is for developers testing payment forms and anyone curious how the check digit works.
If it says valid, does that mean the card works?
No. The Luhn check only confirms the number is mathematically well-formed, like checking that a car’s VIN looks correct. It cannot see whether the card is active, expired, blocked, or has any money on it; only the issuing bank knows that. A valid result simply means the digits pass the checksum that catches most typos.
Which card types does this recognize?
Visa, Mastercard, American Express, Discover, Diners Club and JCB. Each network has its own prefix, called the IIN or BIN: Visa starts with 4, Mastercard with 51–55 or 2221–2720, American Express with 34 or 37, and Discover with 6011, 644–649 or 65. The validator reads that prefix and checks the length against the network, so a 16-digit number starting 37 is not called American Express, whose numbers are 15 digits.
Why do some made-up numbers still pass?
Because the Luhn algorithm only checks the checksum, not whether the number was ever issued. Roughly one in ten random 16-digit numbers will pass by chance. The check digit exists to catch typos: swap two neighbouring digits in a real number and it will almost always fail, which is exactly its job.
How long is a credit card number?
Card numbers in use today are 13 to 19 digits. Mastercard numbers are 16 and American Express 15; Discover, JCB and most Diners Club ranges run from 16 to 19, and Diners Club numbers starting 36 from 14. The validator accepts anything from 13 to 19 digits, runs the Luhn check, then checks the length against the network the prefix names.
What is the Luhn algorithm?
The Luhn algorithm (also called the mod-10 algorithm) is a simple checksum formula used to validate identification numbers, most famously credit card numbers. Hans Peter Luhn patented it in 1960. It works by doubling every second digit from the right, subtracting 9 from any result above 9, summing all the digits, and checking whether the total is divisible by 10. Card networks, banks and payment forms use it as a first-pass check to catch mistyped numbers before a payment is attempted.
Why did my card fail the Luhn check?
A Luhn failure almost always means a typo: a wrong, missing, transposed or extra digit. Re-enter the number carefully, including the final check digit. If a genuinely correct, active card number fails, make sure you have all 13 to 19 digits and that no leading or trailing digits were dropped. Remember the Luhn check only tests the math of the digits: a number can pass and still belong to a card that is expired, blocked or empty.
Can I use this as a Luhn calculator or checker?
Yes. Paste any number and it runs the Luhn (mod-10) checksum and tells you instantly whether it passes, along with the detected card brand. It validates an existing number rather than generating one. For software testing, use the test card numbers Stripe publishes for its test mode, such as 4242 4242 4242 4242 for Visa or 3782 822463 10005 for American Express, which pass the Luhn check without being real accounts.
Last updated October 23, 2026. Validates card-number format with the Luhn (mod-10) algorithm; it does not check whether a card is active or has funds.