Skip to content
💳

Credit Card Validator

Validate card numbers with the Luhn check and detect the brand.

Runs in your browser

Updated

Brand

—

Format check only: a valid checksum does not mean a real or active card. Never enter a real card number on a page you do not trust — this one runs entirely in your browser.

Strip, check, detect, sum

The input is stripped of spaces and dashes, then tested as digits only; a letter or a plus sign stops the check with "Digits only". A surviving number is matched against brand prefixes, its length is checked against a 13 to 19 digit window, and the last step is the Luhn sum: walk from the right, double every second digit, subtract nine whenever the result passes nine, and add. A total divisible by ten earns "Valid number".

A worked example

4111 1111 1111 1111 keeps its 16 digits and is labelled Visa. Doubling alternate digits and adding gives 30, so the verdict is "Valid number". Change the final digit to 2 and the total becomes 31, flipping the verdict to "Invalid checksum". The Amex test number 378282246310005 is 15 digits, labelled American Express, and sums to 60. Thirteen zeros sum to zero and are reported valid.

Brand rules and their edges

Visa is anything starting with 4; Mastercard is 51 to 55 or the 2-series; Amex is 34 or 37; Discover is 6011, 65 or 644 to 649; JCB is 35; Diners Club is 300 to 305, 36 or 38; UnionPay is 62. The 2-series test starts at 2220 rather than the 2221 the scheme specifies, so 2220 0000 0000 0000 is labelled Mastercard. Five digits beginning with 4 show the Visa label and then a wrong-length message, because the brand is read first.

Where it stops

  • Luhn only proves the digits add up; it says nothing about whether an account exists.
  • No verification value field, no expiry date and no issuer lookup beyond the brand.
  • No per-brand length rule, so a 16-digit Amex passes the window.
  • Prefixes are hard-coded, so new ranges are not picked up.

Questions people ask

Is it safe to paste a real card number?

Nothing leaves the browser and nothing is stored, but test with published numbers and keep real ones off any page you do not control.

Why does a card my bank accepts come back invalid?

Some stored-value and gift cards do not use Luhn, and one mistyped digit changes the total. To model repayment on a real balance, use the credit card payoff calculator, and for the rate itself see the APR calculator.