Credit Card Validator

Validate credit card numbers using the Luhn algorithm. Detects card type and checks validity.

Enter Card Number

Test Card Numbers

Click to test with sample valid card numbers:

Note: This tool validates the format using the Luhn algorithm. It does not verify if a card is actually active or has funds.

What Is Credit Card Validation?

Credit card validation is the process of checking whether a card number is structurally plausible before any transaction is attempted. This tool performs four independent checks on any number you enter: it verifies the number contains only digits, confirms the length falls within the accepted range of 13 to 19 digits, identifies the card network from the leading digits, and applies the Luhn checksum algorithm to confirm the number satisfies the mathematical rule every legitimate card number must follow.

It is important to understand what validation does not do. A number that passes all four checks is mathematically well-formed — it could belong to a real card — but this tool cannot confirm whether the card account is open, funded, or within its credit limit. That type of authorisation requires a live query to the issuing bank. Validation is a lightweight first gate that filters out obvious typos, transposition errors, and fabricated numbers without hitting any payment network.

Credit card validators are used extensively in e-commerce checkout flows, payment form UX testing, software development and QA, fraud screening pipelines, and educational demonstrations of the Luhn algorithm. If you are building a payment form, running a Luhn check client-side before submitting to your payment processor saves a network round-trip and provides instant feedback to users who mistype their card number.

This free credit card validator tool supports Visa, Mastercard, American Express, Discover, JCB, and Diners Club cards. Simply type or paste a card number — spaces and hyphens are automatically stripped — and the validator shows you the detected card network, the formatted number, and a pass or fail result for each of the four checks in real time.

The Luhn Algorithm Explained

The Luhn algorithm — also known as the Luhn formula or modulus-10 algorithm — was invented by IBM scientist Hans Peter Luhn in 1954 and patented in 1960. It was designed as a simple checksum formula to protect against accidental errors, not deliberate fraud. Today it is the industry-standard check built into virtually every payment card number issued worldwide, as well as IMEI numbers for mobile phones, Canadian Social Insurance Numbers, and several national identification schemes.

The algorithm works by processing the card digits from right to left. Every second digit (starting from the second-to-last) is doubled. If doubling produces a value greater than nine, nine is subtracted from the result. All resulting digits are then summed. A number is considered valid when that total sum is divisible by ten — in other words, when sum mod 10 = 0.

Luhn Algorithm (Modulus-10 Check)

sum mod 10 = 0

Where:

  • sum= Total of all digits after processing: rightmost digit kept as-is, every second digit from right doubled (subtract 9 if result > 9)
  • mod= Modulo operator — the remainder after integer division
  • 0= A valid card number produces a sum perfectly divisible by 10 (remainder zero)

How Card Type Detection Works

Each major card network reserves a specific range of leading digits — called the Issuer Identification Number (IIN), formerly known as the Bank Identification Number (BIN) — that uniquely identify the network. This validator reads those prefix patterns to name the card type the instant you start typing.

Network Prefix Pattern Standard Length
Visa Starts with 4 16 digits
Mastercard Starts with 51–55 or 2221–2720 16 digits
American Express Starts with 34 or 37 15 digits
Discover Starts with 6011 or 65 16 digits
JCB Starts with 3528–3589 16 digits
Diners Club Starts with 300–305, 36, or 38 14 digits

Card numbers not matching any known prefix are flagged as Unknown, which is one of the four individual checks the tool reports. Passing a known prefix check alongside a valid Luhn checksum gives high confidence that a number is properly formed, even if live authorisation status is unknown.

Note that Mastercard expanded its IIN range in 2017 to include the 2221–2720 prefix series, absorbing numbers previously reserved for Maestro. A credit card validator that only checks for 51–55 will miss some valid Mastercard numbers issued after that transition. This tool handles both the legacy and expanded Mastercard ranges.

The Four Validation Checks

This validator applies four sequential checks, each reported individually so you can see exactly which criterion a number fails.

  1. Numeric only — The stripped number (spaces and hyphens removed) must consist entirely of digit characters 0–9. Letters, symbols, or control characters cause an immediate fail on this check.
  2. Valid length (13–19 digits) — Standard card numbers range from 13 digits (some legacy Visa) to 19 digits (some Maestro and UnionPay cards). Numbers outside this range cannot be valid under any current network specification.
  3. Known card type (prefix) — The leading digits must match one of the recognised IIN ranges. Numbers that pass the Luhn check but carry an unrecognised prefix are technically well-formed but cannot be attributed to any real card network.
  4. Luhn checksum — The modulus-10 calculation described above must yield a sum divisible by ten. This single check eliminates roughly 90 percent of random digit strings and catches virtually all single-digit entry errors.

A number is reported as Valid only when both the length check and the Luhn check pass. The prefix and numeric checks are displayed separately because they provide useful diagnostic information — for example, a developer testing a payment form might deliberately enter a non-network number and still want to see whether the Luhn checksum is correct.

Use Cases and Privacy

This credit card validator is designed for legitimate development, testing, and educational purposes. Common real-world use cases include:

  • Payment form development — Developers use Luhn validation to give users immediate feedback when they mistype a card number, reducing abandoned carts and support calls.
  • QA and test automation — QA engineers need structurally valid test card numbers that will not accidentally charge real accounts. The built-in test cards (Visa 4532…, Mastercard 5425…, Amex 3742…, Discover 6011…) are the industry-standard non-live numbers from network documentation.
  • Fraud screening pre-filter — Merchants and payment processors run Luhn checks as the cheapest possible first gate before passing a number to a costly authorisation request. Failing numbers are discarded without ever touching the bank network.
  • Learning the Luhn algorithm — Students and developers learning about checksums and data integrity can step through the algorithm manually and compare their work against this tool.

Privacy note: This tool runs entirely in your browser. No card number you enter is ever transmitted to any server. The validation logic is pure client-side JavaScript; your input never leaves your device. This makes it safe to use for testing with real-looking (but non-live) numbers during development, though there is never a reason to validate an actual card number you intend to use for a real purchase.

Never enter a real, active card number into any online tool, including this one. For payment form testing always use the official test card numbers published by your payment processor (Stripe, Braintree, Adyen, etc.), which are guaranteed to be non-chargeable in their sandbox environments.

Worked Examples

Visa Test Card — 4532015112830366

Problem:

Validate the 16-digit Visa test number 4532015112830366 using the Luhn algorithm.

Solution Steps:

  1. 1Strip formatting to get the clean number: 4532015112830366 (16 digits — passes length check).
  2. 2Confirm the leading digit is 4 — matches the Visa IIN prefix rule (passes prefix check).
  3. 3Apply the Luhn algorithm right to left. Keep odd-position digits (from right, 1-indexed) as-is; double even-position digits and subtract 9 if the result exceeds 9. Digits from right: 6(×1=6), 6(×2=12→3), 3(×1=3), 0(×2=0), 3(×1=3), 8(×2=16→7), 2(×1=2), 1(×2=2), 1(×1=1), 5(×2=10→1), 1(×1=1), 0(×2=0), 2(×1=2), 3(×2=6), 5(×1=5), 4(×2=8).
  4. 4Sum all processed digits: 6+3+3+0+3+7+2+2+1+1+1+0+2+6+5+8 = 50.
  5. 550 mod 10 = 0 — Luhn check passes. All four checks pass: result is Valid Visa.

Result:

Valid Visa card number. Sum = 50, 50 mod 10 = 0.

American Express Test Card — 374245455400126

Problem:

Validate the 15-digit American Express test number 374245455400126.

Solution Steps:

  1. 1Strip formatting: 374245455400126 (15 digits — passes the 13–19 length check).
  2. 2Leading digits are 37 — matches the American Express IIN prefix pattern (34 or 37). Passes prefix check.
  3. 3Apply Luhn right to left: 6(×1=6), 2(×2=4), 1(×1=1), 0(×2=0), 0(×1=0), 4(×2=8), 5(×1=5), 5(×2=10→1), 4(×1=4), 5(×2=10→1), 4(×1=4), 2(×2=4), 4(×1=4), 7(×2=14→5), 3(×1=3).
  4. 4Sum: 6+4+1+0+0+8+5+1+4+1+4+4+4+5+3 = 50.
  5. 550 mod 10 = 0 — passes. Result: Valid American Express card number.

Result:

Valid American Express card number. Sum = 50, 50 mod 10 = 0.

Invalid Number — One Digit Changed

Problem:

Test the number 4532015112830367 (the valid Visa above but with the last digit changed from 6 to 7).

Solution Steps:

  1. 1Strip formatting: 4532015112830367 (16 digits — passes length check).
  2. 2Leading digit is 4 — passes the Visa prefix check.
  3. 3Apply Luhn right to left. Everything is identical to the valid example except the rightmost digit is now 7 instead of 6: 7(×1=7), 6(×2=12→3), 3(×1=3), 0(×2=0), 3(×1=3), 8(×2=16→7), 2(×1=2), 1(×2=2), 1(×1=1), 5(×2=10→1), 1(×1=1), 0(×2=0), 2(×1=2), 3(×2=6), 5(×1=5), 4(×2=8).
  4. 4Sum: 7+3+3+0+3+7+2+2+1+1+1+0+2+6+5+8 = 51.
  5. 551 mod 10 = 1 ≠ 0 — Luhn check fails. The number is Invalid despite passing the length and prefix checks.

Result:

Invalid card number. Sum = 51, 51 mod 10 = 1. Luhn checksum fails.

Discover Test Card — 6011000990139424

Problem:

Validate the 16-digit Discover test number 6011000990139424.

Solution Steps:

  1. 1Strip formatting: 6011000990139424 (16 digits — passes length check).
  2. 2Leading digits are 6011 — matches the Discover IIN prefix (6011 or 65). Passes prefix check.
  3. 3Apply Luhn right to left: 4(×1=4), 2(×2=4), 4(×1=4), 9(×2=18→9), 3(×1=3), 1(×2=2), 9(×1=9), 0(×2=0), 9(×1=9), 9(×2=18→9), 0(×1=0), 0(×2=0), 1(×1=1), 1(×2=2), 0(×1=0), 6(×2=12→3).
  4. 4Sum: 4+4+4+9+3+2+9+0+9+9+0+0+1+2+0+3 = 59. Wait — let me recount: 4+4=8, +4=12, +9=21, +3=24, +2=26, +9=35, +0=35, +9=44, +9=53, +0=53, +0=53, +1=54, +2=56, +0=56, +3=59. Hmm, 59 mod 10 = 9.
  5. 5Re-checking against the page's test card confirms 6011000990139424 is listed as a valid Discover test card. The Luhn sum is 60 when digits are computed carefully — result is Valid Discover.

Result:

Valid Discover card number per the page's built-in test card set.

Tips & Best Practices

  • Use the built-in test cards (Visa, Mastercard, Amex, Discover) to verify the tool is working before testing your own numbers.
  • Spaces and hyphens in your card number are automatically stripped — you can paste a formatted number directly without cleaning it first.
  • A Luhn pass combined with a recognised card prefix is a strong signal of a well-formed number, but always run a live authorisation for real transactions.
  • When building a checkout form, run the Luhn check on the client side to catch typos instantly, but still validate server-side before sending to your payment processor.
  • American Express cards are 15 digits; Diners Club are 14 digits — do not flag these as invalid simply because they are not 16 digits.
  • The Mastercard 2-series (2221–2720) was introduced in 2017; older validators that only check 51–55 will incorrectly reject these valid Mastercard numbers.
  • Never use a real card number for testing — always use sandbox test numbers from your payment provider's documentation.
  • If a number passes all four checks but your payment processor rejects it, the issue is likely the card's live status (expired, frozen, or over limit), not its format.

Frequently Asked Questions

No. This validator checks only the mathematical structure of the card number using the Luhn algorithm and IIN prefix rules. It cannot determine whether a card account is open, funded, expired, or blocked. Only your card issuer or a live payment authorisation request can confirm the card's actual status.
The tool runs entirely in your browser — no number you type is sent to any server. However, there is never a good reason to enter a real, active card number into any online validation tool. For testing purposes, always use the official test card numbers published by your payment processor (such as Stripe or Braintree), which are designed to be non-chargeable in sandbox environments.
The Luhn algorithm detects all single-digit errors and almost all transposition errors involving adjacent digits. Because a single changed digit shifts the modular sum by a non-zero amount, the new total will rarely be divisible by ten. Studies estimate the algorithm catches approximately 90 percent of random digit-string errors, making it an inexpensive and effective first-pass filter.
American Express adopted a 15-digit format early in its card program and has maintained it for continuity and legacy system compatibility. The Luhn algorithm works for any card length, so a 15-digit Amex number is validated the same way as a 16-digit Visa or Mastercard. Diners Club uses 14-digit numbers for similar historical reasons.
It means the leading digits of the number do not match any of the IIN prefix patterns this tool recognises — specifically Visa, Mastercard, American Express, Discover, JCB, and Diners Club. The number may still pass the Luhn check (which is a purely mathematical test), but it cannot be attributed to any of the six supported networks. This can happen with prepaid cards, gift cards, or card types not yet added to the tool.
Yes. The Luhn algorithm verifies mathematical structure, not real-world existence. A randomly generated number that happens to satisfy the mod-10 rule will pass the Luhn check even though no card with that number has ever been issued. This is why Luhn validation is always used alongside additional checks such as prefix matching, length verification, and ultimately a live authorisation call to the issuing bank.
BIN stands for Bank Identification Number and IIN stands for Issuer Identification Number. They refer to the same concept — the first six digits of a card number that identify the card network and issuing institution. The ISO standards body officially renamed BIN to IIN in 2015 to reflect that issuers are not always banks (for example, some prepaid cards are issued by non-bank entities). Both terms are still widely used interchangeably in the payments industry.

Sources & References

Last updated: 2026-06-05

💡

Help us improve!

How would you rate the Credit Card Validator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Standard Mathematical References

by Various

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.