N-Nitroso contaminants in medicinal products are of concern due to their high carcinogenic potency; however, not all these compounds are created equal, and some are relatively benign chemicals. Understanding the structure−activity relationships (SARs) that drive hazards in one molecule versus another is key to both protecting human health and alleviating costly and sometimes inaccurate animal testing. Here, we report on an extension of the CADRE (computer-aided discovery and REdesign) platform, which is used broadly by the pharmaceutical and personal care industries to assess environmental and human health endpoints, to predict the carcinogenic potency of N-nitroso compounds. The model distinguishes compounds in three potency categories with 77% accuracy in external testing, which surpasses the reproducibility of rodent cancer bioassays and constraints imposed by limited (high-quality) data. The robustness of predictions for more complex pharmaceuticals is maximized by capturing key SARs using quantum mechanics, that is, by hinging the model on the underlying chemistry versus chemicals in the training set. To this end, the present approach can be leveraged in a quantitative hazard assessment and to offer qualitative guidance using electronic structure comparisons between well-studied analogues and unknown contaminants.