The aims of this study were to characterize antibiotic choices for perioperative total knee arthroplasty (TKA) and total hip arthroplasty (THA) prophylaxis, assess antibiotic allergy testing efficacy, and determine rates of prosthetic joint infection (PJI) based on perioperative antibiotic regimen. We evaluated all patients undergoing primary TKA or THA at a single academic institution between January 2004 and May 2017, yielding 29 695 arthroplasties (22 705 patients), with 3411 arthroplasties in 2576 patients (11.5%) having undergone preoperative allergy testing. A series of institutional databases were combined to identify allergy consultation outcomes, perioperative antibiotic regimen, and infection-free survivorship until final follow-up. Among 2576 allergy-tested patients, 2493 patients (97%) were cleared to use cephalosporins. For the entire cohort, 28 174 arthroplasties (94.9%) received cefazolin and 1521 (5.1%) received non-cefazolin antibiotics. Infection-free survivorship was significantly higher among arthroplasties receiving cefazolin compared with non-cefazolin antibiotics, with 0.06% higher survival free of infection at one month, 0.56% at two months, 0.61% at one year, and 1.19% at ten years (p < 0.001). Overall, the risk of PJI was 32% lower in patients treated with cefazolin after adjusting for the American Society of Anesthesiologists (ASA) classification, joint arthroplasty (TKA or THA), and body mass index (BMI; p < 0.001). The number needed to treat with cefazolin to prevent one PJI was 164 patients at one year and 84 patients at ten years. Therefore, potentially 6098 PJIs could be prevented by one year and 11 905 by ten years in a cohort of 1 000 000 primary TKA and THA patients. PJI rates are significantly higher when non-cefazolin antibiotics are used for perioperative TKA and THA prophylaxis, highlighting the positive impact of preoperative antibiotic allergy testing to increase cefazolin usage. Given the low rate of true penicillin allergy positivity, and the readily modifiable risk factor that antibiotic choice provides, we recommend perioperative testing and clearance for all patients presenting with penicillin and cephalosporin allergies. Cite this article: Bone Joint J 2019;101-B(6 Supple B):9-15.