SafetyDataSheetAPI is a product of Dscvry. Explore Dscvry →

Technical · 4 November 2026

Validate every CAS number.

How to validate a CAS number: the check digit, with code and errors from real SDS PDFs. How the CAS Registry Number check digit works, a short validator in Python, and the error we found in public safety data sheets: a concentration glued to the CAS number.

Topic
Technical
Published
4 November 2026
Reading time
3 minutes

Key takeaways

  • The last digit of a CAS number is a checksum of the others. A one-digit misreading fails it most of the time, so the check costs nothing and catches a lot.
  • In 16 public SDS PDFs we found 40 distinct CAS numbers. 37 passed. All 3 failures came from one document, where the PDF's text layer joined a concentration bound to the CAS number.
  • A failed check digit says the number is wrong, not what it should be. Suggest likely readings, never apply them silently.

How the check digit works#

A CAS Registry Number has three parts: two to seven digits, two digits, and one check digit, for example 7732-18-5 (water). Take every digit except the last, read them from right to left, multiply each by its position (1, 2, 3 ...), add up the products and take the remainder after dividing by 10. That remainder must equal the check digit.

For water: the digits before the check digit are 7, 7, 3, 2, 1, 8. From the right that is 8, 1, 2, 3, 7, 7, so the sum is 8×1 + 1×2 + 2×3 + 3×4 + 7×5 + 7×6 = 105. 105 mod 10 is 5, which matches the last digit.

A validator in a few lines#

def cas_is_valid(cas):
    parts = cas.strip().split("-")
    if len(parts) != 3 or not all(p.isdigit() for p in parts):
        return False
    if not (2 <= len(parts[0]) <= 7 and len(parts[1]) == 2 and len(parts[2]) == 1):
        return False
    digits = (parts[0] + parts[1])[::-1]
    total = sum((i + 1) * int(d) for i, d in enumerate(digits))
    return total % 10 == int(parts[2])

Before you call it, normalise what SDSs actually contain: typographic dashes, a "CAS No." prefix, padded leading zeros, several CAS numbers in one cell, and words such as "Trade secret" or "Proprietary" where the number is withheld. A withheld number is not an error. Treat it separately.

What we found in public SDS PDFs#

We downloaded 16 safety data sheets that suppliers publish openly: solvents, aerosol paints, cleaners and coatings from the US, UK and Australia. 15 had a text layer; one was a scanned image. We pulled the text out with the open-source pypdf library and ran every CAS-shaped number through the same check our API now runs.

  • 40 distinct CAS numbers across the 15 text documents.
  • 37 passed the check digit.
  • 3 failed, all in one paint SDS: 3013463-67-7, 101317-65-3 and 51332-58-7.

The PDF itself was fine. In its text layer the concentration column ran straight into the CAS column, so "≤30" followed by 13463-67-7 (titanium dioxide) came out as one number. The same happened with "≤10" and 1317-65-3 (limestone), and "≤5" and 1332-58-7 (kaolin). Any pipeline that reads the text layer, whether it uses rules, OCR or a language model, can inherit this error, and the record would carry a CAS number that looks plausible and belongs to nothing.

This was a small, informal sample, not a benchmark. It shows the kind of error a check digit catches.

Suggest, don't fix#

A failed check digit tells you the number is wrong. It does not tell you the right one. Our validator adds one deterministic hint: if dropping one to three leading digits gives a valid CAS number, it reports that as a possible reading. For the paint SDS it suggests exactly 13463-67-7, 1317-65-3 and 1332-58-7. The record itself is never changed, and a person confirms against the PDF.

In the API#

Every extraction now returns validation.cas: each Section 3 entry with its status (valid, invalid_check_digit, invalid_format, withheld, not_provided), the canonical form, any possible reading, and the parsed concentration range. Failures also appear in validation.issues with the field path, so a review queue can jump straight to composition[2].cas_number. EC numbers get their own check digit (modulo 11) in the same pass.

Frequently asked questions

Does a valid check digit mean the CAS number is right?

No. It means the number is well-formed. A different valid number, for the wrong substance, also passes. Compare against the substance name or your own substance master data for anything critical.

What about CAS numbers marked trade secret?

OSHA allows a specific chemical identity or exact concentration to be withheld as a trade secret. These are reported as withheld, at info level, and do not count as errors.

Do EC numbers have a check digit too?

Yes. Multiply the first six digits by 1 to 6, add them up and take the remainder after dividing by 11; it must equal the last digit. ECHA list numbers that start with 6 to 9 are only format-checked.