BACKGROUND : International Classification of Diseases (ICD) code algorithms are routinely used to estimate the frequency of illicit injection drug use (IDU)-associated hospitalizations in administrative health datasets despite a lack of evidence regarding their validity. We aimed to measure the sensitivity and specificity of ICD code algorithms used to estimate the prevalence of current/recent IDU among infective endocarditis (IE) hospitalizations without a reference standard. METHODS : We reviewed medical records of 321 patients aged 18-64 years old from an urban academic hospital with an IE diagnosis between 2007 and 2017. Diagnostic tests for IDU included self-reported IDU in medical records; a drug use, abuse and dependence (UAD) ICD algorithm; a Hepatitis C Virus (HCV) ICD algorithm; and a combination drug UAD/HCV ICD algorithm. Sensitivity, specificity and the misclassification error (ME)-adjusted IDU prevalence were estimated using Bayesian latent class models. RESULTS : The combination algorithm had the highest sensitivity and lowest specificity. Sensitivity increased for the drug UAD algorithm in the ICD-10 period compared to the ICD-9 period. The ME-adjusted current/recent IDU prevalence estimated using the drug UAD and HCV algorithms was 23 % (95 % Bayesian credible interval: 16 %, 31 %). The unadjusted prevalence estimate from the drug UAD algorithm underestimated the ME-adjusted prevalence, while the combination algorithm overestimated it. CONCLUSIONS : The validity of ICD code algorithms for IDU among IE hospitalizations is imperfect and differs between ICD-9 and ICD-10. Commonly used ICD-based algorithms could lead to substantially biased prevalence estimates in IDU-associated hospitalizations when using administrative health data.