Background and aims Electronic health record (EHR)-based research allows the capture of large amounts of data, which is necessary in NAFLD, where the risk of clinical liver outcomes is generally low. The lack of consensus on which International Classification of Diseases (ICD) codes should be used as exposures and outcomes limits comparability and generalizability of results across studies. We aimed to establish consensus among a panel of experts on ICD codes that could become the reference standard and provide guidance around common methodological issues. Approach and results Researchers with an interest in EHR-based NAFLD research were invited to collectively define which administrative codes are most appropriate for documenting exposures and outcomes. We used a modified Delphi approach to reach consensus on several commonly encountered methodological challenges in the field. After two rounds of revision, a high level of agreement (>67%) was reached on all items considered. Full consensus was achieved on a comprehensive list of administrative codes to be considered for inclusion and exclusion criteria in defining exposures and outcomes in EHR-based NAFLD research. We also provide suggestions on how to approach commonly encountered methodological issues and identify areas for future research. Conclusions This expert panel consensus statement can help harmonize and improve generalizability of EHR-based NAFLD research.