dev.codes
check digits for cards, ISBNs and IBANs; HTTP status and MIME type lookups
Example results generated on 2026-10-08. Ones using
now,todayor randomness will differ when you run them: press Run on any example to run it in your browser, after editing it if you like.
Functions
| function | description |
|---|---|
luhn(s: str|int) | whether the Luhn check digit is right, as on credit cards and IMEIs; spaces and dashes are ignored |
isbn(s: str) | whether an ISBN-10 or ISBN-13 has a valid check digit |
iban(s: str) | whether an IBAN passes its mod-97 check |
http_status(code: int) | the reason phrase for an HTTP status code, or nil |
mime(name: str) | the MIME type for a file name or extension, or nil |
luhn
luhn(s: str|int): whether the Luhn check digit is right, as on credit cards and IMEIs; spaces and dashes are ignored
luhn("4111 1111 1111 1111")
# → true
luhn(79927398710)
# → false
isbn
isbn(s: str): whether an ISBN-10 or ISBN-13 has a valid check digit
isbn("0-306-40615-2")
# → true
isbn("9780306406157")
# → true
See also: luhn
iban
iban(s: str): whether an IBAN passes its mod-97 check
iban("GB82 WEST 1234 5698 7654 32")
# → true
See also: luhn
http_status
http_status(code: int): the reason phrase for an HTTP status code, or nil
http_status(404)
# → "Not Found"
(200..=204).map(http_status)
# → ["OK", "Created", "Accepted", "Non-Authoritative Information", "No Content"]
See also: mime
mime
mime(name: str): the MIME type for a file name or extension, or nil
mime("png")
# → "image/png"
mime("data.json")
# → "application/json"
See also: ext
More examples
codes
# a typo in a card number?
luhn("4111 1111 1111 1112")
# → false
# valid ISBN?
isbn("978-0-306-40615-7")
# → true
# what's a 418?
http_status(418)
# → "I'm a teapot"
# Content-Type for a file
mime("report.pdf")
# → "application/pdf"