dev.codes
catch typos in card numbers, ISBNs and IBANs, and look up HTTP status codes and file types
Check digits for card, book and bank account numbers, and lookups for HTTP status codes and file types. A check digit is an extra digit worked out from the others, so mistyping or swapping a digit almost always makes the whole number invalid.
good to know
Section titled “good to know”Passing the check only means a number is well formed, not that the card, book or account exists.
Tags: encoding
luhnwhether a number passes the Luhn check, the check digit on credit cards and phone IMEIsisbnwhether an ISBN-10 or ISBN-13 has a valid check digitibanwhether an international bank account number (IBAN) passes its check (the whole number mod 97 must be 1)http_statusthe standard name for an HTTP status code, like “Not Found” for 404, or nil if it isn’t onemimethe MIME type for a file name or extension, like “image/png”, which is what a web server sends as Content-Type, or nil if unknown
Functions
Section titled “Functions”luhn(s: str|int) -> bool
whether a number passes the Luhn check, the check digit on credit cards and phone IMEIs
Spaces and dashes are ignored
1luhn("4111 1111 1111 1111")true2luhn(79927398710)falseisbn(s: str) -> bool
whether an ISBN-10 or ISBN-13 has a valid check digit
1isbn("0-306-40615-2")true2isbn("9780306406157")trueSee also luhn
iban(s: str) -> bool
whether an international bank account number (IBAN) passes its check (the whole number mod 97 must be 1)
1iban("GB82 WEST 1234 5698 7654 32")trueSee also luhn
http_status
Section titled “http_status”http_status(code: int) -> str|nil
the standard name for an HTTP status code, like “Not Found” for 404, or nil if it isn’t one
1http_status(404)"Not Found"2(200..=204).map(http_status)["OK", "Created", "Accepted", "Non-Authoritative Information", "No Content"]See also mime
mime(name: str) -> str|nil
the MIME type for a file name or extension, like “image/png”, which is what a web server sends as Content-Type, or nil if unknown
1mime("png")"image/png"2mime("data.json")"application/json"See also ext
More examples
Section titled “More examples”1# a typo in a card number?2luhn("4111 1111 1111 1112")false3# valid ISBN?4isbn("978-0-306-40615-7")true5# what's a 418?6http_status(418)"I'm a teapot"7# Content-Type for a file8mime("report.pdf")"application/pdf"Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.