Credit Card Validator & Luhn Checker
Client-side Luhn algorithm (Mod 10) checksum and card brand validator for developer payment form testing and sandbox integration.
Developer Testing & Educational Utility Only
This tool checks the mathematical structure of credit card numbers using the client-side Luhn algorithm (Mod 10 checksum) and network IIN/BIN specifications. It cannot check account balances, verify if a card is active, validate CVV/CVC codes, or process payments. All computations occur locally in your browser—no card numbers are sent across the network or stored.
Check Luhn Algorithm & Card Brand
Test card number format, length, and checksum compliance for checkout form development and sandbox integration.
Load Gateway Sandbox Test Numbers
Official test cards recognized by Stripe, PayPal/Braintree, and payment sandbox environments
Lengths: 13, 16, 19 digits
Starts with 4
Lengths: 16 digits
Starts with 5 or 2
Lengths: 15 digits
Starts with 34 or 37
Lengths: 16 digits
Starts with 6
Lengths: 14 digits
Starts with 30, 36, 38, 39
Lengths: 15, 16 digits
Starts with 2131, 1800, or 35
Lengths: 16, 17, 18, 19 digits
Starts with 62 or 88
Lengths: 12, 13, 14, 15, 16, 17, 18, 19 digits
Starts with 50, 56, 57, 58, or 6
Developer Testing & Sandbox Notice
This utility is designed exclusively for software developers, QA engineers, and educators testing payment form validation logic, input masking, and checkout error handling. Card numbers tested here are evaluated solely for mathematical checksum validity. This page does not verify account status, does not check available balances, and cannot be used to execute financial transactions. Always use official test card numbers in your payment gateway sandbox environment.
Validation Capabilities & Limitations
✓ What This Validator Checks
- Luhn Mod 10 Checksum: Verifies if the digits pass the mathematical check digit calculation.
- Network Identification (BIN/IIN): Identifies card brand (Visa, Mastercard, Amex, Discover, JCB, Diners Club, UnionPay, Maestro) based on ISO/IEC 7812 prefix rules.
- Length Verification: Ensures the digit count matches network specifications (e.g., 15 for Amex, 16 for Mastercard, 13–19 for Visa).
- Client-Side Execution: All validation happens in local JavaScript; zero network requests are made.
✗ What This Validator Cannot Do
- Verify Active Accounts: Cannot determine if a card number belongs to an active bank account.
- Check Credit or Balance: Cannot query bank balances or credit limits.
- Validate CVV/CVC Codes: CVV verification requires the issuing bank's private cryptographic keys and cannot be verified offline.
- Authorize Charges: Cannot authorize or settle payment transactions.
How the Luhn Algorithm (Mod 10) Works
The Luhn algorithm (ISO/IEC 7812-1) is a simple checksum formula used to validate primary account numbers against accidental typing errors. The last digit of a payment card number is the check digit, calculated so that the overall number satisfies the Luhn formula.
Step-by-Step Calculation:
- Starting from the rightmost digit (excluding the check digit) or moving right to left: double every second digit.
- If doubling a digit results in a number greater than 9 (e.g., 8 × 2 = 16), add the digits together or subtract 9 (1 + 6 = 7, or 16 - 9 = 7).
- Sum all doubled results and untouched alternate digits together with the check digit.
- If the grand total modulo 10 equals 0 (
sum % 10 === 0), the number is mathematically valid.
JavaScript Luhn Implementation:
function validateLuhn(cardNumber) {
const digits = cardNumber.replace(/\D/g, "");
let sum = 0;
let shouldDouble = false;
// Traverse digits from right to left
for (let i = digits.length - 1; i >= 0; i--) {
let digit = parseInt(digits.charAt(i), 10);
if (shouldDouble) {
digit *= 2;
if (digit > 9) digit -= 9;
}
sum += digit;
shouldDouble = !shouldDouble;
}
return sum % 10 === 0;
}Official Payment Gateway Sandbox Test Cards
When developing and testing e-commerce checkout flows, payment processors provide dedicated sandbox card numbers to simulate different processing scenarios without incurring actual charges:
| Payment Gateway | Card Brand | Sandbox Test Card Number | Simulated Outcome |
|---|---|---|---|
| Stripe | Visa | 4242 4242 4242 4242 | Successful payment |
| Stripe | Visa | 4000 0000 0000 0002 | Card declined: Insufficient funds |
| Stripe | Visa | 4000 0000 0000 0115 | Triggers 3D Secure authentication |
| PayPal / Braintree | Visa | 4111 1111 1111 1111 | Successful authorization |
| PayPal / Braintree | Mastercard | 5555 5555 5555 4444 | Successful authorization |
| PayPal / Braintree | American Express | 3782 822463 10005 | Successful authorization |
| Square | Visa | 4111 1111 1111 1111 | Approved sandbox transaction |
Card Network Prefix & Length Rules
The first 6 to 8 digits of a credit card represent the Issuer Identification Number (IIN), previously called the Bank Identification Number (BIN). The leading digit represents the Major Industry Identifier (MII):
Visa
Leading digit: 4
Valid lengths: 13, 16, 19 digits
Mastercard
Leading digits: 51–55, 2221–2720
Valid lengths: 16 digits
American Express
Leading digits: 34, 37
Valid lengths: 15 digits
Discover
Leading digits: 6011, 622, 644–649, 65
Valid lengths: 16, 19 digits
Frequently Asked Questions
What is the Luhn algorithm and how does it work?
The Luhn algorithm (also known as the Mod 10 checksum) is a mathematical formula developed by IBM scientist Hans Peter Luhn in 1954. It validates the integrity of identification numbers by doubling every second digit from right to left, summing the digits (subtracting 9 if doubling exceeds 9), and checking if the total sum is evenly divisible by 10. It instantly detects all single-digit entry errors and nearly all transposition mistakes.
Does passing the Luhn check mean a card is real and has available credit?
No. The Luhn algorithm is solely a mathematical checksum verifying that the digits conform to standard credit card formatting rules. It does not check whether an account exists, whether it is open, if it has funds, or if the name and expiration match. Confirming account status requires an active payment gateway (such as Stripe, PayPal, or Braintree) communicating with the issuing bank.
What are official payment gateway sandbox test cards?
Major payment processors provide predetermined test card numbers for staging and development. For example, Stripe standard test Visa is 4242 4242 4242 4242, and PayPal/Braintree uses 4111 1111 1111 1111 for successful test authorizations. These numbers satisfy the Luhn algorithm and allow developers to simulate successful payments, declines, insufficient funds, and 3D Secure challenges without moving real funds.
Why can't an offline tool validate CVV/CVC codes?
Card Verification Value (CVV2 / CVC2) codes are calculated cryptographically using the card primary account number (PAN), expiration date, service code, and a secret Card Verification Key (CVK) known only to the issuing bank. Because this key is never public, no offline software or validator can verify a CVV code—verification can only be completed by the issuer during payment authorization.
Is it safe to test card numbers on this website?
All validation logic on Stilest executes strictly client-side inside your web browser. No numbers are transmitted to our servers or stored in any database. However, as a security best practice, developers and QA teams should only enter simulated numbers or official payment sandbox test cards, never live card details.
How should developers implement card validation in production applications?
Production checkout forms should use client-side Luhn validation only for immediate user input formatting and typo detection. Actual card data must be tokenized directly using hosted fields or SDKs from PCI-DSS certified payment gateways (like Stripe Elements, Braintree Drop-in, or PayPal SDK) so that unencrypted card numbers never touch your application servers.
Other Developer Tools
Need a Brain Break? ☕
Done working on your task? Take a quick 60-second break, test your reflexes, and flap through infinite pixel obstacles in Sky Flap!