Skip to main content
CodeLint.Dev Dev Tools

Credit Card Number Validator — Luhn Check

Luhn checksum validation and card network identification, computed locally. No card number is transmitted.

Credit Card Validator

Luhn checksum · card type detection · 100% client-side

Test:
Enter a card number above or click a test card to get started.

⚠ For testing only. These are standard test card numbers — never enter real card data online.

The Luhn algorithm

A checksum designed in 1954 to catch the errors humans actually make — single mistyped digits and most adjacent transpositions.

Double every second digit from the right; subtract 9 from any result above 9; sum all digits; valid if the total is divisible by 10

Step 1
Starting from the rightmost digit, double every second digit
Step 2
If a doubled value exceeds 9, subtract 9 (equivalent to summing its digits)
Step 3
Sum every digit
Step 4
The number is valid if the sum mod 10 equals 0

Worked example

Number
4532 0151 1283 0366
After doubling alternates
8 5 6 2 0 1 10→1 1 2 2 16→7 3 0 3 12→3 6
Sum
60
60 mod 10
0

Valid Luhn checksum

Luhn catches all single-digit errors and most transpositions of adjacent digits — the exception being 09 ↔ 90. It is an error-detection code, not a security measure: anyone can generate a Luhn-valid number in a line of code.

Identifying the network

NetworkStarts withLength
Visa413, 16 or 19
Mastercard51–55, or 2221–272016
American Express34 or 3715
Discover6011, 622126–622925, 644–649, 6516–19
JCB3528–358916–19
Diners Club300–305, 36, 38–3914–19
UnionPay6216–19
RuPay60, 65, 81, 82, 50816
Maestro5018, 5020, 5038, 6304, 6759, 6761–676312–19

About

The Credit Card Validator uses the Luhn algorithm (also known as the "modulus 10" or "mod 10" algorithm) to verify the mathematical validity of a card number. It also detects the card brand by matching known issuer identification patterns (IIN prefixes) and validates that the number length matches the expected length for that brand. All processing happens in your browser — no card data is ever transmitted to a server.

How to use

  1. 1 Type or paste a card number into the input field — spaces are accepted and stripped automatically.
  2. 2 The tool formats the number with proper group spacing as you type (4-4-4-4 for Visa, 4-6-5 for Amex, etc.).
  3. 3 The card brand (Visa, Mastercard, Amex, Discover, JCB, UnionPay, Maestro, RuPay, Diners) is detected in real time.
  4. 4 The Luhn checksum is computed and shown as Pass or Fail.
  5. 5 The digit count is checked against the valid lengths for the detected brand.
  6. 6 Use the quick-test buttons to load known-valid test card numbers for each brand.
What is the Luhn algorithm?
The Luhn algorithm is a simple checksum formula used to validate credit card numbers, IMEI numbers, and other identification numbers. It was developed by IBM scientist Hans Peter Luhn in 1954. Starting from the rightmost digit, every second digit is doubled. If the doubled value exceeds 9, subtract 9. Sum all the digits. If the total is divisible by 10, the number is valid. The algorithm detects single-digit transcription errors and most transposition errors, making it useful as a quick sanity check — though it is not a security measure.
Does a valid Luhn result mean the card is real?
No. A valid Luhn check only means the number passes the mathematical checksum — it does not mean the card account exists, is active, or has funds. Any sufficiently crafted 16-digit number with the right checksum will pass Luhn validation. Real card authorization requires network communication with the card issuer. This tool is useful for testing payment flows with realistic-looking test numbers, not for verifying real card accounts.
What test card numbers can I use for payment testing?
Major payment processors publish official test card numbers for sandbox environments. Common ones include: Visa 4111111111111111, Mastercard 5500000000000004, Amex 371449635398431, Discover 6011111111111117. These all pass Luhn validation. For Stripe, Adyen, Braintree, and others, check their respective developer documentation for the full list of test numbers that trigger specific responses (decline, insufficient funds, etc.).