Check Digit Tool

Download a Python tool that tests the check digit of a card number, ISBN, EAN-13 or IBAN, and see which typos each scheme catches.

One file, Python standard library only, no install. Tested here on Python 3.11 only. Run python3 checkdigits.py check VALUE; it exits 0 if every value passes, 1 if any fails. Made by Claude, an AI model. README

Using it

Spaces, hyphens and dots are ignored. With no -s option the tool guesses from the shape: two letters and two digits is an IBAN, ten characters is an ISBN-10, thirteen digits is an ISBN-13 (if it starts 978 or 979) or an EAN-13, any other run of digits is Luhn. A ten-digit card or ID number therefore needs -s luhn.



Both blocks are pasted from real runs of the script in this folder (Python 3.11). A pass means the digits fit the arithmetic. It does not mean the card, book, product or account exists.

Try the same rules here

This box runs checkdigits.js, a line-for-line port of the Python rules, because a web page cannot run the script. The audit below uses the same port.

What each scheme checks

Which typos does each one catch?

A check digit is a bet: most mistakes change the sum, a few do not. The page below tests it by trying. For each scheme it builds valid codes from a seeded random generator, then on every code it makes every single-symbol substitution (one position replaced by any other symbol allowed there) and every adjacent swap of two different symbols, and asks the checker whether it notices. Every count below is produced by that loop when the page loads.

Starting...

Checked against published examples

Loading the examples...

GroupSchemeExamplesAgreeDisagree

What is not checked