Luhn checksum plus brand prefix and length rules, computed locally.
🔒 Format check only: Luhn checksum plus brand prefix/length rules, computed entirely in your browser. "Valid" means well-formed — it says nothing about whether the account exists, and nothing is ever sent anywhere.
The Credit Card Validator is based on the following formula:
valid ⟺ Σ digits (double every 2nd from the right, −9 if > 9) ≡ 0 (mod 10)
Variables: digits = card number with spaces/dashes stripped (12-19 digits) Σ = running sum, computed right to left mod 10 = divisibility by ten of the final sum brand = IIN prefix (first 6-8 digits) + per-brand length rules
Luhn doubles every second digit from the right, subtracts 9 from any doubled value over 9, and requires the total to be a multiple of 10. Brand detection is separate: the issuer prefix (e.g. 4 = Visa, 51-55/2221-2720 = Mastercard, 34/37 = Amex) must also match the brand's allowed lengths.
Worked example: Step 1: input 4111 1111 1111 1111 (Visa test number, 16 digits). Step 2: from the right, the 1s at even positions 2,4,6,8,10,12,14 double to 2 each → 7 × 2 = 14. Step 3: the leading 4 sits at even position 16, doubles to 8 (not over 9, no subtraction). Step 4: odd positions 1,3,5,7,9,11,13,15 hold eight undoubled 1s → 8. Step 5: total = 14 + 8 + 8 = 30; 30 mod 10 = 0 → checksum PASS. Result: prefix 4 with 16 digits matches Visa, and the Luhn sum is divisible by 10 — the number is structurally valid (this matches the tool's output on the default sample).
The checksum (IBM, 1954) doubles every second digit from the right, subtracts 9 from any result over 9, and requires the total to be a multiple of 10. That construction catches every single-digit typo and almost every transposed pair — the exact mistakes humans make when typing or reading numbers aloud. It was never security; it is a typo fence, and it is still embedded in every card terminal and payment form on the planet.
The first 6-8 digits are the Issuer Identification Number. Visa starts with 4; Mastercard with 51-55 or 2221-2720; Amex with 34 or 37 and is 15 digits, which is why Amex fields group as 4-6-5 instead of 4-4-4-4; Discover uses 6011, 65, 644-649 or 622126-622925. A number can pass Luhn and still have the wrong length for its brand — both checks must agree before "valid" means anything.
This tool runs entirely in your browser and checks structure only: shape, brand and checksum. It cannot know whether the account is open, funded, or past its fraud rules — only the issuing bank knows that, at authorization time. That is why payment test numbers like Visa's 4111 1111 1111 1111 are published openly: they are structurally perfect and connected to nothing.
Luhn plus brand-length rules are the right client-side gate before you ever call a payment API: they stop the 16th-digit typo from becoming a failed charge attempt and a confused user. Amex's 15 digits and 4-6-5 grouping deserve their own input mask, and switching the card icon by prefix is a small trust signal users notice.
More tools you might find useful
Click-to-build cron schedules with live plain-English preview.
Byte-safe CSS compression: calc() spaces, strings and /*! banners survive.
Convert CSV data to a JSON array using the header row.
CSV in, batched multi-row INSERTs out — with escaping and NULL options.