ToolNimba Browse

💳 Credit Card Number Validator (Luhn)

By ToolNimba Web Dev Team · Updated 2026-06-19

This tool checks the number's maths only. A “valid” result means the digits pass the Luhn checksum, not that the card is real, active, or has funds. Use test numbers here, never a number you do not own. Nothing is stored or sent anywhere.

Enter a card number above and press Check number.

This credit card validator checks whether a card number is well-formed and tells you which brand it belongs to. Paste the number (spaces and dashes are fine), and the tool runs the Luhn checksum to say pass or fail, then detects the brand from the leading digits: Visa, Mastercard, American Express, or Discover. It is built for developers and testers who need to validate input formats. Important: this only checks the maths, not whether the card is real, active, or has any money on it. Everything runs in your browser, so nothing you type is stored or sent anywhere.

What is the Credit Card Validator?

Almost every credit and debit card number carries a built-in error-detecting digit. The last digit (the check digit) is chosen so that the whole number satisfies the Luhn algorithm, a simple mod-10 checksum invented by IBM's Hans Peter Luhn in the 1950s. When you mistype or transpose a digit, the checksum almost always fails, which lets a payment form catch the slip before it ever reaches the bank. That is exactly what this tool replicates: it is a format check, not an account lookup.

The algorithm works from the rightmost digit leftwards. Every second digit is doubled, and if doubling produces a number above 9 you subtract 9 (the same as adding the two digits together). You then add up all the resulting digits. If that total is a multiple of 10, the number passes. Because the test is purely arithmetic, it can be run entirely on the client with no network call, which is why this page never transmits anything.

Brand detection is separate from the checksum and relies on the Issuer Identification Number, the first few digits. Visa cards start with 4. Mastercard uses 51 to 55 plus the newer 2221 to 2720 range. American Express begins with 34 or 37 and is 15 digits long. Discover starts with 6011 or 65. A number can pass the Luhn check yet still be an unknown brand, because Luhn validity and brand prefixes are two independent properties.

When to use it

  • Testing a checkout or payment form with known-good and known-bad numbers before going live.
  • Validating card-number input on the client so users catch typos instantly, before submitting.
  • Generating or checking test card numbers (such as the brand sandboxes) during development.
  • Teaching or learning how the Luhn algorithm and Issuer Identification Numbers actually work.

How to use the Credit Card Validator

  1. Paste or type the card number into the field. Spaces and dashes are allowed and ignored.
  2. Press Check number (or just keep typing, it validates as you go).
  3. Read the verdict: whether it passes the Luhn checksum and which brand the prefix matches.
  4. Use the checksum total and digit count to debug a number that fails.

Formula & method

Luhn (mod 10): starting from the rightmost digit, double every second digit; if a doubled value exceeds 9, subtract 9. Sum all digits. The number is valid when the total mod 10 = 0.

Worked examples

Validate the Visa test number 4539 1488 0343 6467.

  1. Strip spaces: 4539148803436467 (16 digits).
  2. From the right, double every second digit and subtract 9 if over 9:
  3. 4→8, 5→5, 3→6, 9→9, 1→2, 4→4, 8→7, 8→8, 0→0, 3→3, 4→8, 3→3, 6→3, 4→4, 6→3, 7→7
  4. Add them up: 8+5+6+9+2+4+7+8+0+3+8+3+3+4+3+7 = 80
  5. 80 mod 10 = 0, so the checksum passes.
  6. First digit is 4, so the brand is Visa.

Result: Passes the Luhn check, brand Visa, checksum total 80.

Check the short string 4539 to see why length and checksum both matter.

  1. Strip spaces: 4539 (only 4 digits).
  2. From the right: 9 stays, 3→6, 5 stays, 4→8.
  3. Sum = 9 + 6 + 5 + 8 = 28.
  4. 28 mod 10 = 8, not 0, so the checksum fails.
  5. It is also far shorter than the 13 to 19 digits a real card uses.

Result: Fails the Luhn check (total 28) and is too short to be a card number.

Brand detection by prefix and length

BrandStarts withTypical length
Visa413, 16 or 19
Mastercard51-55 or 2221-272016
American Express34 or 3715
Discover6011 or 6516

Common test numbers (sandbox use only, all pass Luhn)

NumberBrandLuhn
4111 1111 1111 1111VisaPass
5555 5555 5555 4444MastercardPass
3714 496353 98431American ExpressPass
6011 0009 9013 9424DiscoverPass

Common mistakes to avoid

  • Thinking a “valid” result means the card is real. The Luhn check only proves the digits are internally consistent. It says nothing about whether the card was ever issued, is active, or has funds. Only the card network and issuing bank can confirm that, and this tool never contacts them.
  • Trusting brand detection as proof of issuer. Prefix ranges identify the likely brand but are not airtight. New ranges (like Mastercard 2221-2720) are added over time, and some prefixes overlap with other card types, so treat the brand as a best guess from the leading digits.
  • Forgetting to strip spaces and dashes. Numbers are often written in groups (4539 1488 0343 6467). If your own code runs Luhn on the raw string without removing separators, every number will fail. This tool strips spaces and dashes before checking.
  • Running Luhn on the wrong number of digits. A truncated or padded number can sometimes still pass by coincidence. Always check the length too: 15 digits for Amex, 16 for most others, and 13 to 19 overall.

Glossary

Luhn algorithm
A mod-10 checksum that doubles every second digit (subtracting 9 when over 9) and checks the total is a multiple of 10. Also called the modulus 10 algorithm.
Check digit
The final digit of a card number, chosen so the whole number satisfies the Luhn check. It catches most single-digit typos and transpositions.
Issuer Identification Number (IIN)
The first 6 to 8 digits of a card number that identify the network and issuing institution. The leading digits decide the brand.
Brand
The card network, such as Visa, Mastercard, American Express or Discover, identified here by the prefix.
Transposition error
Swapping two adjacent digits when typing. The Luhn check detects almost all such mistakes, which is its main purpose.

Frequently asked questions

What does this credit card validator actually check?

It runs the Luhn (mod-10) checksum to confirm the digits are mathematically consistent, and it reads the leading digits to guess the brand. It does not check whether the card exists, is active, or has any balance. It is a format validator, not an account lookup.

What is the Luhn algorithm?

The Luhn algorithm is a simple checksum used by almost all card numbers. Starting from the right, you double every second digit (subtracting 9 if the result is over 9), add all the digits together, and the number is valid only if the total is a multiple of 10. It catches most typos and transposed digits.

Can a number pass the Luhn check but still be a fake card?

Yes. The Luhn check only proves the digits are well-formed. Anyone can construct a number that passes it, including the standard test numbers used by payment sandboxes. Whether a card is genuine and usable can only be confirmed by the card network and issuing bank.

How does the tool detect the card brand?

It looks at the leading digits. Visa starts with 4, Mastercard with 51-55 or 2221-2720, American Express with 34 or 37, and Discover with 6011 or 65. If the prefix matches none of these, the brand is shown as Unknown.

Is it safe to enter a card number here?

The tool runs entirely in your browser using plain JavaScript, with no network requests and no storage, so nothing you type leaves your device. Even so, you should only enter test numbers or numbers you own, never someone else’s card details.

Why does my real card fail the check?

The most common cause is a typo or a transposed pair of digits, which is exactly what the Luhn check is designed to catch. Re-enter the full number carefully, including all 15 or 16 digits, and make sure no digit is missing or duplicated.