BACKGROUND: Nonsteroidal anti-inflammatory drugs (NSAIDs) can increase fluid retention and the risk of heart failure (HF). Type 2 diabetes mellitus (T2DM) is known to increase the risk of cardiac disease, including HF. As part of a modern multimodal pain protocol, NSAIDs are commonly used in total knee arthroplasty (TKA), but the risk of NSAID use in TKA for T2DM patients is not well understood. The purpose of this study was to compare rates of new-onset HF following TKA in Type 2 diabetics with varying NSAID use. METHODS: We reviewed 3,906 patients who underwent primary TKA from 2015 to 2023 at a single academic institution. Data collected included demographics, preoperative diagnosis of T2DM, postoperative development of new-onset HF, NSAIDs taken perioperatively, and aspirin use for deep vein thrombosis (DVT) prophylaxis. Propensity matching was conducted to control for age, American Society of Anesthesiologists (ASA) Score, and aspirin use. Rates of postoperative HF within T2DM patients who took meloxicam versus celecoxib were compared using Chi-square analyses. RESULTS: Among patients who took meloxicam or celecoxib perioperatively, a preoperative diagnosis of T2DM was disproportionately associated with postoperative HF (P = 0.006). When comparing peri-TKA use of meloxicam versus celecoxib in T2DM patients, the use of celecoxib was disproportionately associated with the development of postoperative HF (2.2% [meloxicam], 4.8% [celecoxib], P = 0.002). CONCLUSIONS: We found patients who had T2DM developed postoperative HF at higher rates compared to non-diabetics following peri-TKA NSAID use and that T2DM patients developed new-onset HF at higher rates when utilizing celecoxib than meloxicam in the peri-TKA period. Along with the many other factors that contribute to an orthopaedic surgeon's decision on which NSAID to use postoperatively, we advocate for consideration of the risk of new-onset HF in T2DM patients when prescribing meloxicam and celecoxib in the post-TKA period.