checkersCredit Card Validator

Credit Card Validator

Validate credit card numbers using the Luhn algorithm

For Testing Only

This tool validates card number format only. Never enter real credit card information on untrusted websites. This validation is for educational and testing purposes.

Enter 13-19 digit card number

Free Credit Card Validator | Check Card Number Format and Luhn Validity Online

Virtually every credit card number in use satisfies the Luhn algorithm, a simple checksum formula used to detect typos and transposition errors in card numbers. When a customer miskeys a single digit on a payment form, the Luhn check catches it instantly before any network request reaches the payment processor.

Thetoolity's free credit card validator applies the Luhn algorithm to any 13 to 19 digit card number and tells you whether the number passes or fails the checksum. It also identifies which card network the number belongs to based on its prefix and length.

This tool is designed for developers building or testing payment forms, educators explaining how card number validation works, and anyone curious about the mathematics of card number structure. It is not a tool for processing payments or verifying real card accounts.

For testing, use the test card numbers provided by your payment processor. Do not enter real card numbers into any online tool.

How to Use the Credit Card Validator

  • Step 1: Enter a card number in the input field. The tool accepts 13 to 19 digits. Type digits only: the tool adds the spaces for you as you type, and any other character (such as a hyphen or a letter) is ignored.

  • Step 2: Read the result. There is no button to press. As soon as you have entered 13 digits, the tool applies the Luhn algorithm and shows either "Valid Card Number" (the number satisfies the Luhn checksum) or "Invalid Card Number" (it does not).

  • Step 3: Check the card information. For a valid number, the tool also shows the probable card network based on the number's prefix (IIN/BIN) and length: Visa, Mastercard, American Express, or Discover. Numbers from other networks are reported as Unknown.

  • Step 4: Review the validation checks. Three quick checks show whether the input contains only digits, has a valid length (13 to 19 digits), and passes the Luhn check.

  • Step 5: Use the result for its intended purpose: confirming that your payment form's Luhn validation logic is working correctly, understanding why a specific number is rejected by payment validation, or learning how card number structure works.

What this tool does

  • Checks whether the card number satisfies the Luhn algorithm checksum

  • Identifies the probable card network from the prefix and length

  • Accepts 13 to 19 digit numbers matching real card number length ranges

What this tool does not do

  • Confirm the card account exists at any bank

  • Verify the card expiry date or CVV

  • Check available balance or credit limit

  • Process or attempt any payment transaction

  • Access any payment network or financial system

What Is the Luhn Algorithm?

The Luhn algorithm (also known as the Luhn formula or modulus 10 algorithm) is a simple checksum formula invented by IBM scientist Hans Peter Luhn in the 1950s. It was designed as a method to validate identification numbers and protect against accidental errors such as single-digit typos and digit transpositions.

The algorithm is not a cryptographic security measure. It was created for error detection, and it is used far beyond payment cards: for example in IMEI numbers on mobile phones and Canadian Social Insurance Numbers. Card networks adopted it as a convenient built-in check that any computer or even a simple calculator can perform.

Because the algorithm is publicly documented and widely known, passing the Luhn check does not mean a card number is real, active, or belongs to anyone. It only means the digits form a mathematically consistent sequence that could be a valid card number.

How the Luhn algorithm works

  • Step 1: Starting from the rightmost digit (the check digit) and moving left, keep the first digit, double the second, keep the third, and so on. In other words, double every second digit.

  • Step 2: If doubling a digit produces a result greater than 9, subtract 9 from the result (this is equivalent to adding the two digits of the doubled value).

  • Step 3: Sum all the digits (the doubled and adjusted ones, plus the unchanged ones).

  • Step 4: If the total sum is divisible by 10 (that is, the sum modulo 10 equals 0), the number passes the Luhn check.

Worked example with a Visa test card number

Card number: 4111 1111 1111 1111 (16 digits). Working from right to left:

  • The digits in positions 1, 3, 5, 7, 9, 11, 13, and 15 are kept as they are. All eight of them are 1, so they add up to 8.

  • The digits in positions 2, 4, 6, 8, 10, 12, and 14 are doubled. Each is a 1, so each becomes 2, and the seven of them add up to 14.

  • The leftmost digit (position 16) is a 4. It is doubled to 8.

  • Total: 8 + 14 + 8 = 30. Since 30 divided by 10 leaves a remainder of 0, the number passes the Luhn check.

Why typos fail the Luhn check

If a customer enters 4111 1111 1111 1112 instead of 4111 1111 1111 1111 (one digit changed at the end), the sum becomes 31 rather than 30. 31 modulo 10 equals 1, not 0. The check fails and the form can reject the number immediately without contacting the payment network.

The Luhn algorithm catches every single-digit error and nearly all transpositions of two adjacent digits (the one exception is swapping 0 and 9 next to each other, such as 09 becoming 90). It does not catch all possible errors, such as some multi-digit mistakes, but it is very effective as a fast first-line check.

Card Number Structure by Network

Credit and debit card numbers follow specific structures defined by each card network. The first few digits (called the Issuer Identification Number or IIN, formerly called the Bank Identification Number or BIN) identify the card network and issuing bank. The length of the number varies by network.

Visa

  • Length: 16 digits (some older cards have 13 digits)

  • Prefix: always starts with 4

  • Example format: 4XXX XXXX XXXX XXXX

Visa is one of the largest card networks in the world, and its numbers are among the easiest to identify because of the consistent 4 prefix and 16-digit length.

Mastercard

  • Length: 16 digits

  • Prefix: 51 through 55 (classic range) or 2221 through 2720 (range added in 2017)

  • Example format: 5XXX XXXX XXXX XXXX or 2XXX XXXX XXXX XXXX

Mastercard expanded its IIN range in 2017 to include the 2-series (2221 to 2720), which is why some newer Mastercard numbers start with 2 rather than 5.

American Express (Amex)

  • Length: 15 digits

  • Prefix: 34 or 37

  • Example format: 3XXX XXXXXX XXXXX (grouped as 4-6-5)

American Express cards are notably different from Visa and Mastercard in two ways: they are 15 digits rather than 16, and they are typically displayed in a 4-6-5 grouping rather than the standard 4-4-4-4 grouping.

Discover

  • Length: 16 digits (some ranges allow up to 19)

  • Prefix: 6011, 644 through 649, 65, or the 622126 to 622925 range (shared with China UnionPay)

  • Example format: 6XXX XXXX XXXX XXXX

China UnionPay (CUP)

  • Length: 16 to 19 digits

  • Prefix: 62

UnionPay is the largest card network by total number of issued cards, though it is primarily used within China. It is accepted at an increasing number of international merchants. Note that this tool reports only Visa, Mastercard, American Express, and Discover by name, so other networks appear as Unknown.

Maestro and debit networks

Maestro (Mastercard's international debit network) and various regional debit networks have varying IIN prefixes and lengths (12 to 19 digits). Identification is more complex than for the major credit networks.

Why card network identification matters for developers

When building payment forms, knowing the card network from the prefix allows the form to:

  • Display the correct card logo dynamically as the user types

  • Apply the correct input mask (16 digits in groups of 4 for Visa and Mastercard versus 15 digits in 4-6-5 for Amex)

  • Enable or disable payment methods not accepted by the merchant

  • Apply network-specific CVV length validation (3 digits for Visa, Mastercard, and Discover, 4 digits for Amex)

What the Luhn Check Does and Does Not Confirm

Understanding the precise scope of Luhn validation prevents misunderstandings about what this tool can tell you.

What a Luhn pass confirms

  • The digit sequence forms a mathematically valid card number pattern

  • The number has a length that fits the identified card network

  • The number would not be immediately rejected by the first layer of client-side payment form validation that most e-commerce sites use

What a Luhn pass does not confirm

  • The card account exists at any bank or financial institution

  • The card has not expired

  • The card has not been cancelled or frozen

  • The card has any available credit or funds

  • The card belongs to any real person

  • The CVV/CVC/CID matches any card

  • The billing address matches any card

A Luhn-valid number that does not correspond to a real issued card will fail the moment it is submitted to a payment processor's authorization network. Real-time card authorization (which checks actual account status, available funds, and fraud signals) is performed by the payment processor through the card network and the issuing bank. Luhn validation is only the most basic first-level check, performed by the merchant's form before any network communication.

Randomly generated Luhn-valid numbers

It is mathematically possible to generate numbers that pass the Luhn check but have never been issued to any cardholder. These numbers are used for payment system testing. Payment processors provide official sets of test card numbers. For example, the Stripe test card 4242 4242 4242 4242 is Luhn-valid, starts with 4, and is 16 digits, but it is specifically configured in Stripe's test environment to simulate a successful payment.

Test Card Numbers for Developers

Software developers building and testing payment integrations should always use the official test card numbers provided by their payment processor. These numbers are:

  • Luhn-valid (they pass the checksum)

  • Configured in the test environment to simulate specific outcomes (success, decline, insufficient funds, expired card)

  • Safe to use repeatedly in development without any financial impact

  • Not chargeable in production environments

Stripe test cards (partial list, for educational reference)

  • Visa, successful payment simulation: 4242 4242 4242 4242

  • Visa, card declined simulation: 4000 0000 0000 0002

  • Mastercard, successful payment: 5555 5555 5555 4444

  • Amex, successful payment: 3782 8224 6310 005

  • Discover, successful payment: 6011 1111 1111 1117

For any integration, always refer to your payment processor's own documentation for the current complete list of test cards and the specific behaviors each simulates.

Never use test card numbers in production

Test cards are recognized and rejected by production payment systems. Using them in production code causes authorization failures.

Why Credit Card Numbers Have a Check Digit

The Luhn algorithm produces what is called a check digit, the final digit of the card number. This digit is not assigned arbitrarily: it is calculated from all the other digits in the number so that the entire sequence satisfies the Luhn checksum.

When a card network or issuing bank generates a new card number, the process works as follows:

  • The IIN (the first 6 to 8 digits) identifies the network and issuing bank.

  • The account number portion (the following digits) identifies the specific account.

  • The final check digit is calculated from all preceding digits using the Luhn algorithm to make the complete number Luhn-valid.

This structure means that if any single digit in a 16-digit card number is changed, the Luhn check fails. This is what makes it effective at catching single-digit data entry errors.

PAN (Primary Account Number)

The technical term for the card number is PAN, or Primary Account Number. A complete PAN includes the IIN, the account number, and the check digit. The PAN appears embossed on the physical card and encoded in the magnetic stripe and chip.

PCI DSS and PAN handling

The Payment Card Industry Data Security Standard (PCI DSS) governs how card data must be handled by any business that accepts card payments. Key requirements include:

  • Never storing sensitive authentication data, such as the CVV, after authorization

  • Storing the PAN only when there is a business need, and rendering it unreadable (through strong encryption, truncation, or tokenization)

  • Displaying only a truncated version of the PAN wherever possible

  • Never transmitting the PAN over unencrypted networks

  • Protecting systems that handle PANs from unauthorized access

Thetoolity's credit card validator never stores, transmits, or logs any card number entered. All validation happens locally in your browser using JavaScript.

Frequently Asked Questions

What does a credit card validator do?+
A credit card validator applies the Luhn algorithm to a card number to check whether its digits form a mathematically valid sequence. It also identifies the card network (Visa, Mastercard, Amex, Discover) from the number's prefix and length. It does not confirm the card account exists, check the balance, verify expiry, or access any payment system.
What is the Luhn algorithm?+
The Luhn algorithm is a checksum formula invented by IBM scientist Hans Peter Luhn in the 1950s. It works by doubling every second digit from the right, adjusting values above 9 by subtracting 9, then summing all digits. If the total is divisible by 10, the number passes. Virtually all legitimate credit card numbers satisfy this check. It detects every single-digit typo and nearly all swaps of two adjacent digits.
Can I use this tool to check if my credit card is valid?+
No. A Luhn check only validates the mathematical structure of the digit sequence. It cannot tell you whether your card account is open, active, not expired, or has available funds. For account status, contact your card issuer. Additionally, you should never enter a real card number into any online tool.
How many digits are in a credit card number?+
Credit card numbers are 13 to 19 digits long depending on the card network. Visa uses 16 digits (some older cards use 13). Mastercard uses 16 digits. American Express uses 15 digits. Discover uses 16 digits. China UnionPay uses 16 to 19 digits.
How do I identify the card network from a card number?+
The first digits of a card number identify the network. Cards starting with 4 are Visa. Cards starting with 51 through 55 or 2221 through 2720 are Mastercard. Cards starting with 34 or 37 and 15 digits long are American Express. Cards starting with 6011, 644 through 649, or 65 are Discover.
Is it safe to enter a credit card number into an online validator?+
You should not enter a real, active credit card number into any online tool as a general practice. Thetoolity's validator processes all data locally in your browser with nothing transmitted to any server. However, the safer practice is to use officially provided test card numbers from your payment processor when testing validation logic. Real card numbers should only be entered into legitimate, PCI-compliant payment forms.
What is the difference between Luhn validation and real card authorization?+
Luhn validation checks only the mathematical structure of the digit sequence. It runs instantly in the browser without any network communication. Real card authorization is performed by the payment processor through the card network and the issuing bank, verifying that the account exists, the card is not expired, the CVV matches, sufficient funds exist, and no fraud signals are present. Luhn validation is the first fast check. Authorization is the definitive check.
What is a BIN or IIN?+
BIN (Bank Identification Number) is the older term for the first digits of a card number, now officially called the IIN (Issuer Identification Number). It was traditionally 6 digits and can now be up to 8. The IIN identifies both the card network and the issuing bank, and payment systems use it to route authorization requests to the correct network and issuing institution.

Why Thetoolity?

Thetoolity brings together a growing collection of free, fast, and clean online tools for developers, QA engineers, and anyone learning about payment systems. Our credit card validator applies the Luhn algorithm instantly in your browser, identifies the card network from the IIN prefix, and provides a clear pass or fail result, all without transmitting any data to any server.

No accounts. No subscriptions. No cluttered interfaces. No card data stored or transmitted. Just a clean, instant card number format check for development and educational use.

Explore the full collection at Thetoolity.com and find generators, converters, calculators, checkers, and testers, all free and all instant.

Reminder: this tool is for testing and educational purposes only. Never enter real credit card information into any online tool. Use test card numbers provided by your payment processor for integration testing.