Developer Tools

Credit Card Number Validator | Luhn Algorithm & Brand Detection

Enter a credit card number to verify its check digit with the Luhn algorithm and automatically detect the brand (Visa, Mastercard, Amex, etc.). Handy for testing form validation.

[[ labels.client_side_note ]]


[[ labels.format_error ]]
[[ labels.sample_label ]]:
[[ labels.no_input ]]

[[ labels.result_label ]]

[[ labels.formatted_label ]] [[ result.formatted ]]
[[ labels.brand_label ]] [[ brandName ]] [[ labels.brand_unknown ]]
[[ labels.checksum_label ]] ✓ [[ labels.checksum_valid ]] ✗ [[ labels.checksum_invalid ]]

Supported Brands and Detection Rules (IIN & Length)

Brand Leading Digits (IIN) Length
Visa 4 13, 16, 19
Mastercard 51–55, 2221–2720 16
American Express 34, 37 15
Discover 6011, 65 16
JCB 3528–3589 16
Diners Club 300–305, 36, 38 14
UnionPay 62 16–19

Tips

  • Try the sample buttons for well-known test numbers (e.g. Visa: 4111 1111 1111 1111) instead of a real card number.
  • Spaces and hyphens are stripped automatically, so you can paste a number copied from anywhere.
  • This tool only checks the format via the Luhn algorithm. For real authorization or balance checks, use your payment processor's API.
  • When building form validation, use this tool to generate both a passing case and a failing case to test your logic.

Frequently Asked Questions

No. This tool only performs a Luhn format check — it cannot tell you whether the card actually exists, has been deactivated, or has sufficient funds. Real authorization requires your payment processor's systems.

The number is never sent to a server — all calculation happens in your browser's JavaScript. That said, if you just want to test the tool, we recommend using one of the sample test numbers instead of a real card.

It's an error-detection algorithm devised in 1954 by IBM's Hans Peter Luhn. Starting from the right, every second digit is doubled, and if the total of all digits is a multiple of 10, the format is considered valid. It catches most typos.

It's based on the leading digits (the Issuer Identification Number) combined with the total length. For example, Visa numbers start with "4" and have 13, 16, or 19 digits, Mastercard starts with "51-55" and has 16 digits, and JCB starts with "3528-3589" and has 16 digits — all publicly documented rules. See the "Supported Brands and Detection Rules" table further down this page for the full list.

No. Passing Luhn only confirms the number is internally consistent as a format. Even a made-up 16-digit number can be adjusted at the last digit to pass the Luhn check.
ツールくん

Side Note — Hans Peter Luhn, the Father of the Check Digit

The check digit at the end of a credit card number is verified using an algorithm devised in 1954 by IBM engineer Hans Peter Luhn. He was awarded a patent for it in 1960, but the patent has long since expired, so the algorithm is now free for anyone to use.

The mechanism is surprisingly simple. Starting from the rightmost digit, every second digit is doubled; if the result is two digits, they are added together (e.g. 8×2=16 → 1+6=7). If the sum of all digits is a multiple of 10, the number is considered formally valid.

The algorithm is used well beyond credit cards — it also catches typos in IMEI numbers (used to identify smartphones) and Canadian Social Insurance Numbers, among others. It is worth remembering that Luhn only detects accidental mistypes; it says nothing about whether the card actually exists or has any balance.

The first 6 to 8 digits of a card number form the Issuer Identification Number (IIN), which identifies the card network and issuing bank. This tool's brand detection is based on the publicly documented IIN ranges for each network.