# Credit Card Number Validator (Luhn)

URL: https://hifreetools.com/developer/credit-card-validator

> Paste a card number to run the Luhn checksum and detect its brand by prefix and length. It runs entirely in your browser for developers testing formats — no card data is ever stored or sent.

## Quick answer

The Luhn algorithm is a simple checksum that catches any single-digit typo in card numbers: doubling every second digit from the right, summing the digits, and confirming the total is a multiple of 10. This tool runs that check and identifies the brand from the prefix and length. Passing Luhn means the number is well-formed — not that a real, active card exists.

After stripping spaces and dashes, the number is checked for length (12–19 digits). The Luhn (mod-10) test then walks the digits right to left, doubling every second one and subtracting 9 from any result over 9, then sums them; a total divisible by 10 passes. The brand is inferred from the issuer prefix and length — Visa starts with 4, Mastercard with 51–55 or 2221–2720, American Express with 34 or 37, and Discover with 6011, 65, 644–649, or 622. All computation happens locally in your browser.

## Examples

- Valid Visa test number: 4111 1111 1111 1111 → Passes Luhn · Brand: Visa · 16 digits
- Valid Amex test number: 378282246310005 → Passes Luhn · Brand: American Express · 15 digits
- One digit wrong — fails: 4111 1111 1111 1112 → Fails Luhn · Brand: Visa · 16 digits
- 2-series Mastercard: 2223003122003222 → Passes Luhn · Brand: Mastercard · 16 digits

## FAQ

**Does this store or send my card number?**
No. The check runs entirely in your browser with JavaScript — nothing is uploaded, logged, or stored. That said, you should still only enter published test numbers, never a real card.

**Does a valid result mean the card works?**
No. The Luhn algorithm only verifies that the number is well-formed and free of common typos. It cannot tell you whether the card was ever issued, is active, or has available funds — only the issuing bank can confirm that.

**What is the Luhn algorithm?**
It is a mod-10 checksum invented by Hans Peter Luhn. From the rightmost digit, every second digit is doubled (subtracting 9 if the result exceeds 9), all digits are summed, and the number passes if the total is divisible by 10. It detects every single-digit error and almost all adjacent transpositions (09 ↔ 90 is the exception).

**How is the card brand detected?**
From the issuer identification number (the leading digits) and the total length. For example, 4 with 13/16/19 digits is Visa, 34 or 37 with 15 digits is American Express, and 51–55 or 2221–2720 with 16 digits is Mastercard. These ranges are heuristics and can change.

**Do spaces and dashes matter?**
No. The tool strips all spaces and dashes before checking, so 4111 1111 1111 1111 and 4111-1111-1111-1111 are treated the same as the raw digits.

**Why does my brand show as Unknown?**
The prefix or length didn't match any rule the tool knows. The Luhn result is still shown, but the issuer ranges here cover the major networks (Visa, Mastercard, Amex, Discover, Diners, JCB, Maestro) and not every regional or private-label card.

**Can it validate the CVV or expiry date?**
No. The CVV and expiry are not part of the card number and have no checksum relationship to it. This tool only validates the primary account number (PAN) using Luhn and detects the brand.


## Sources

- [Wikipedia — Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm)
- [Wikipedia — Payment card number (IIN/BIN ranges)](https://en.wikipedia.org/wiki/Payment_card_number)
- [ISO/IEC 7812-1 — Identification cards — Identification of issuers — Part 1: Numbering system](https://www.iso.org/standard/70484.html)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Credit Card Number Validator (Luhn)", https://hifreetools.com/developer/credit-card-validator
