Skip to content
UniKit

Credit card validator

Validate card numbers with the Luhn algorithm, detect Visa, Mastercard, American Express, JCB, Discover, UnionPay and Diners Club, inspect the BIN, length and check digit, and generate Luhn-valid test numbers.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Card number

Everything runs locally: the Luhn algorithm (ISO/IEC 7812-1) only checks the number format and check digit — it does not prove the card exists or is usable.

Spaces and dashes are allowed; 1–19 digits in total.

Generate a test number

The generator only guarantees a valid check digit and length; the number belongs to no real account.

Generated number

Result

Enter a card number and press “Validate number”, or generate a test number.

What this tool does

  • Pre-check a card number in a checkout or admin form: a mistyped or missing digit shows up in the Luhn check instead of as a gateway error later.
  • Generate a Luhn-valid test number (Visa, Mastercard, Amex, JCB, Discover, UnionPay, Diners Club) before testing a payment flow, so you do not try a real card.
  • Debug "the gateway detected the wrong scheme": the tool reports the first six digits (BIN), the detected scheme, the allowed lengths and the grouping so you can compare item by item.
  • Spot-check formats during data cleanup or reconciliation — just the Luhn and length verdicts, with no network involved.

Example

Input

4111 1111 1111 1111 (a 16-digit Visa test number, typed with spaces)

Output

Digits only: 4111111111111111; scheme Visa; BIN 411111; length 16 (Visa allows 13 / 16 / 19); last digit 1 and the Luhn-derived check digit is also 1; Luhn passed, length passed, number valid

Change the last digit to 2 and the tool reports expected check digit 1 with the Luhn check failing, while still showing Visa and length 16 — every check gets its own verdict instead of a bare false.

Frequently asked questions

Does passing the check mean the card is real?

No. Luhn only verifies the modulo-10 rule and that the length fits the scheme, so an invented number can pass. Whether a card exists or can be charged is up to a payment gateway, and this tool makes no network requests at all.

Why are spaces and dashes accepted?

Spaces and dashes are stripped before parsing, so 4111 1111 1111 1111, 4111-1111-1111-1111 and the bare digits are equivalent. Nothing else is allowed: the input must be digits only, at most 19 of them, and a letter triggers an "invalid card number" message.

Can Diners Club be detected as Mastercard?

The two overlap slightly: the 54 and 55 ranges Diners Club uses in the US and Canada collide with Mastercard, and this tool follows the mainstream convention of assigning them to Mastercard. Discover’s 622126–622925 also sits inside UnionPay’s 62, so the detection order matches Discover first.

Can a generated test number repeat?

In theory yes. The generator only guarantees a prefix inside the scheme’s valid range, an allowed length and a correct check digit; the middle digits are random (rejection sampling avoids modulo bias). That makes it fine for testing but not for unique identifiers.

Is the number stored or uploaded?

It is not uploaded. Validation and generation run entirely in the browser, the page makes no requests, and nothing you type is saved. If you would rather not use a real number, use the built-in example or a generated one.

Keywords:credit card validatorluhn checkcard number checkbin lookupcard brand detect信用卡验证银行卡校验Luhn 算法卡号校验位卡组织识别测试卡号生成

Related tools