About this tool
Credit card transcription errors in e-commerce checkouts and subscription billing portals drive payment rejection spikes and abandoned carts. Standardized under ISO/IEC 7812, virtually all major global payment card networks (Visa, Mastercard, American Express, JCB, UnionPay) employ the Luhn algorithm (Modulus 10) as their final check digit mechanism. This tool validates card numbers locally, identifies Issuer Identification Numbers (BIN/IIN), and detects card brands with zero network storage.
How to Use This Tool (Step-by-Step)
Enter Payment Card Number
Paste or type the credit/debit card number into the field. The parser automatically strips spaces and hyphens.
Execute Luhn Mod 10 Check
The engine runs the Luhn algorithm, doubling alternate digits from right to left to verify check digit integrity.
Inspect Card Brand & IIN Category
The dashboard displays detected card network brand badges (Visa, Mastercard, Amex, UnionPay) and formal validity badges.
Global Card Brand Detection
Leverages Issuer Identification Numbers (IIN/BIN) to identify Visa, Mastercard, Amex, JCB, Discover, and China UnionPay.
Strict ISO/IEC 7812 Luhn Math
Mod 10 checksum calculations catch 100% of single-digit input typos and the vast majority of adjacent digit transpositions.
100% Client-Side Air-Gapped
Evaluations run exclusively in local memory without backend calls. Compliant with PCI-DSS security principles—zero card numbers are stored.
PCI-DSS Compliance & Payment Gateway Tips
- •Luhn validity does not equal live active funds: Luhn validates math syntax, not live bank balances. Only payment gateways can confirm available credit limits.
- •PCI-DSS mandates NEVER storing CVV/CVC codes: Storing security codes after authorization is strictly prohibited under international card scheme regulations.
- •Format input with dynamic spaces: Auto-formatting card numbers into 4-digit blocks reduces cognitive typing fatigue and boosts checkout conversion.
Code & Transformation Examples
Major Payment Card Network IIN Rules Benchmark
• Visa : 首位固定为 '4' (长度 16 位,极少数旧卡 13 位)
• Mastercard : 前缀 51-55 或 2221-2720 (长度 16 位)
• American Express: 前缀 34 或 37 (长度固定 15 位)
• 中国银联 (UnionPay): 前缀 62 (长度通常为 16-19 位)
• JCB : 前缀 3528-3589 (长度 16 位)合法的卡号必须同时满足两个条件:① 符合卡组织官方分配的前缀号段与位数长度;② 必须严格通过 Luhn 模 10 算法校验。* American Express cards use a distinct 15-digit format, unlike the 16-digit norm for Visa/Mastercard.
JavaScript Luhn Algorithm Implementation
function isValidLuhn(cardNumber) {
const sanitized = cardNumber.replace(/\D/g, '');
let sum = 0;
let shouldDouble = false;
for (let i = sanitized.length - 1; i >= 0; i--) {
let digit = parseInt(sanitized.charAt(i), 10);
if (shouldDouble) {
digit *= 2;
if (digit > 9) digit -= 9;
}
sum += digit;
shouldDouble = !shouldDouble;
}
return (sum % 10) === 0;
}console.log(isValidLuhn("49927398716")); // 输出: true
console.log(isValidLuhn("49927398717")); // 输出: false (末位错误)* Double every second digit from right to left; if doubling exceeds 9, subtract 9. Total sum must be divisible by 10.
Frequently Asked Questions
Q: What is an Issuer Identification Number (BIN / IIN)?
A: The first 6 to 8 digits form the Bank Identification Number (BIN/IIN), identifying the card network (Visa, Mastercard) and issuing bank institution.
Q: Why does Luhn miss twin transposition errors?
A: Luhn catches all single-digit errors and adjacent transpositions. Rare twin transposition shifts (e.g., 22 to 55) yield matching sums, which online gateway auth catches.
Q: Is it safe to test my credit card number here?
A: 100% safe. Math runs purely in local browser memory without network calls. Furthermore, without expiration dates and CVVs, numbers cannot be charged.