CHECK DIGIT CALCULATOR

Check digit calculator

Validate a Luhn, ISBN, barcode or IBAN number, or work out its missing check digit.

Sample numbers: 79927398713 (valid), 17893729974 (valid), 79927398710 (wrong). Do not enter real card numbers.

Private by design: the number is not saved and is not part of the Share link. Nothing leaves your browser. Please do not type real card or bank details here.

Check digits quietly protect almost every long number you meet: card numbers, book ISBNs, barcodes and bank account numbers. This page works through the same arithmetic the systems use, so you can verify a number from a form, test an input check in your own program, or learn why one wrong digit gets rejected. It is a calculator for the arithmetic only; it does not look anything up.

What is a check digit?

A check digit is an extra digit added to the end of a number, calculated from all the other digits by a fixed rule. If someone mistypes a digit or swaps two neighbors, the rule usually no longer works and the number can be rejected immediately, before it is looked up or processed. It catches accidental mistakes only: it is not a password, not a signature and not proof that an account, book or product exists.

Is it safe to enter my card number here?

Please do not. This page never sends anything anywhere: the calculation runs in your browser, the number field is not saved on your device and is left out of the Share link. Even so, real card numbers should not be typed into calculators or other pages that have nothing to do with a payment. To try the Luhn check, use a sample number from the page, such as 79927398713, which is a textbook example and not a card.

How does the Luhn algorithm work?

Starting from the right and not counting the check digit, double every second digit; if the result has two digits, subtract 9. Add everything up. The check digit is what you must add to reach a multiple of 10. For 7992739871 the check digit is 3, so the full number 79927398713 has a Luhn total of 70, a multiple of 10. The method was invented by Hans Peter Luhn of IBM (US patent 2,950,048, 1960) and is specified in Annex B of ISO/IEC 7812-1, the standard for identification card numbers, which is why it is known as the check for payment card numbers.

What does the Luhn check not catch?

It catches every single wrong digit and almost all swaps of two neighboring digits. It misses the swap of 09 with 90, and a few pairs of equal-digit mistakes such as 22 ↔ 55. More importantly, it was designed against accidental errors, not against fraud: anyone can produce a number that passes. A valid check therefore says nothing about whether a card or account is real, active or yours.

How is an ISBN check digit calculated?

ISBN-10 multiplies the first nine digits by 10, 9, 8, … 2 and adds the results; the check character makes the total a multiple of 11 (a value of 10 is written X). For 0-306-40615 the weighted sum is 130, so the check character is 2. ISBN-13 multiplies the first 12 digits alternately by 1 and 3; for 978-0-306-40615 the sum is 93 and the check digit is 7. ISBNs assigned from 2007 are 13 digits and start with 978 or 979, the same prefixes used in EAN-13 barcodes, so the page can convert a 10-digit ISBN into its 13-digit form: 9780306406157.

How do UPC and EAN barcodes use the check digit?

UPC-A (12 digits), EAN-13 and EAN-8 use the GS1 rule: counting from the digit next to the check digit, multiply by 3, 1, 3, 1 and so on, add up, and take the amount needed to reach a multiple of 10. For the UPC-A body 03600029145, the digits in odd positions add up to 14, times 3 is 42; the digits in even positions add up to 16; the total 58 needs 2 more to reach a multiple of 10, so the full code is 036000291452. A UPC-A code is the same as an EAN-13 with a leading zero. A correct check digit does not mean the product is registered anywhere.

How is an IBAN checked?

Move the first four characters (country code and two check digits) to the end, replace each letter by a number (A = 10 … Z = 35) and divide the resulting long number by 97. The IBAN is valid only if the remainder is 1. The example GB82 WEST 1234 5698 7654 32, a fictitious account in a UK bank, gives remainder 1; to create the check digits, put 00 in their place, divide by 97 and subtract the remainder from 98, which gives 82 here. This page also checks the total length for GB 22, DE 22, FR 27, NL 18, CH 21, ES 24, IT 27 (the number of characters); other countries are checked by mod 97 only.

Worked example

Take the Luhn number 79927398713. Working from the right, the check digit 3 is kept, the next digit is doubled, the next is kept, and so on. The total of all the digits after doubling is 70, which ends in 0, so the number passes. Change one digit and the total shifts by a number that is not a multiple of 10, so the check fails. For the book 0-306-40615-2, the weighted sum of the first nine digits is 130, and 130 + 2 × 1 is a multiple of 11 (it is 132). The 13-digit version 978-0-306-40615-7 uses weights 1 and 3.

Why these particular rules?

The following explanations are our own derivations from the formulas, not quotations. In the Luhn rule one of two neighboring digits is doubled and the other is not, so swapping them changes the total unless the two digits count the same either way; that happens only for 0 and 9, which is the known 09 / 90 blind spot. The ISBN-10 rule divides by 11, a prime number, and gives neighboring positions weights that differ by 1, so a swap of two different neighbors changes the weighted sum by their difference, which is never a multiple of 11; the price is the extra character X for the value 10. The EAN/UPC rule with weights 3 and 1 uses only digits, which suits a barcode, but a swap of two neighbors goes unnoticed when the digits differ by exactly 5, because 2 × 5 = 10. The IBAN rule is applied to the whole number as a very long integer, which is why the page computes the remainder piece by piece instead of using ordinary floating-point numbers.

Common mistakes and limits

  • Treating a valid check as proof. The rules are public and a number with a correct check digit can be made up in a second. Passing the test never means that the card, account or ISBN is real. Wikipedia's article on the algorithm puts it the same way: it was designed to protect against accidental errors, not malicious attacks.
  • Counting from the wrong end. The digits that are doubled in the Luhn rule are the one next to the check digit and then every second digit going left. Which digits are doubled decides the answer, so counting from the left can give a wrong verdict.
  • Hyphens, spaces and X. Hyphens and spaces in ISBNs and IBANs are formatting only. In ISBN-10, X (capital) stands for 10 and can only be the last character.
  • Assuming the lengths. This page knows the IBAN lengths of just a few countries (GB 22, DE 22, FR 27, NL 18, CH 21, ES 24, IT 27). For other countries it checks the mod-97 rule but cannot say whether the length and layout are right, so confirm those with the bank or the national registry.
  • Mixing up ISBN-10 and ISBN-13. The two check digits are generally different, even for the same book, because the formulas differ. Convert with the 978 prefix and recalculate.

Sources: Wikipedia, “Luhn algorithm” (H. P. Luhn, US patent 2,950,048, 1960; ISO/IEC 7812-1 Annex B; error coverage), “ISBN” (ISBN-10 weights 10 to 1 modulo 11, ISBN-13 weights 1 and 3), “Universal Product Code” (UPC-A worked example 036000291452, relation to EAN-13) and “International Bank Account Number” (mod-97 procedure, example GB82 WEST 1234 5698 7654 32, lengths for seven countries; ISO 13616 with SWIFT as registrar). The standards themselves (ISO/IEC 7812-1, ISO 13616, GS1 General Specifications) are paywalled or were not retrievable and were not opened. Related: modulo calculator, base converter, password entropy calculator, Caesar cipher and random number generator.