OhMyCalc

Luhn Algorithm Validator

Validate credit card numbers, IMEI codes, and other identifiers using the Luhn checksum algorithm.

How to Use the Luhn Algorithm Validator

  1. Select the mode: Validate number to check an existing number, or Generate check digit to compute a check digit for a partial number.
  2. Enter the digits in the input field (spaces and dashes are ignored automatically).
  3. Click Validate or Generate to run the algorithm.
  4. Review the result and the step-by-step breakdown showing each digit's transformed value and the final sum.

Referência Rápida

DePara
VisaStarts with 4 (16 digits)
MastercardStarts with 51–55 (16 digits)
AmexStarts with 34 or 37 (15 digits)
DiscoverStarts with 6011 (16 digits)
IMEI15 digits, last digit is Luhn check
4532015112830366Valid (Visa test number)

Casos de Uso

Fórmula

The Luhn algorithm (also known as the mod-10 algorithm) validates a number by: (1) starting from the rightmost digit and moving left, double every second digit; (2) if doubling produces a number greater than 9, subtract 9; (3) sum all digits; (4) if the total modulo 10 equals 0, the number is valid.

Perguntas Frequentes

What is the Luhn algorithm used for?
The Luhn algorithm is a simple checksum formula used to validate identification numbers such as credit card numbers (Visa, Mastercard, Amex), IMEI numbers for mobile devices, Canadian Social Insurance Numbers, and various other account identifiers. It detects single-digit errors and most transposition errors.
Does passing the Luhn check mean a card number is real?
No. The Luhn check only verifies that the number is formatted correctly — it confirms the check digit matches the rest of the digits. A number can pass Luhn validation and still not correspond to any real, active account. Card issuers perform additional checks for actual authorization.
How is the Luhn check digit calculated?
Remove the last digit (the check digit). Reverse the remaining digits. Double every digit at an odd index (positions 1, 3, 5 …). Subtract 9 from any doubled value greater than 9. Sum all the resulting digits. The check digit is (10 − (sum mod 10)) mod 10.