Introduction The increasing prevalence of type 2 diabetes mellitus (T2DM) presents a significant burden on affected individuals and healthcare systems internationally. There is, however, no agreed validated measure to infer diabetes severity from electronic health records (EHRs). We aim to quantify T2DM severity and validate it using clinical adverse outcomes. Methods and analysis Primary care data from the Clinical Practice Research Datalink, linked hospitalisation and mortality records between April 2007 and March 2017 for patients with T2DM in England will be used to develop a clinical algorithm to grade T2DM severity. The EHR-based algorithm will incorporate main risk factors (severity domains) for adverse outcomes to stratify T2DM cohorts by baseline and longitudinal severity scores. Provisionally, T2DM severity domains, identified through a systematic review and expert opinion, are: Diabetes duration, glycated haemoglobin, microvascular complications, comorbidities and coprescribed treatments. Severity scores will be developed by two approaches: (1) calculating a count score of severity domains; (2) through hierarchical stratification of complications. Regression models estimates will be used to calculate domains weights. Survival analyses for the association between weighted severity scores and future outcomes-cardiovascular events, hospitalisation (diabetes-related, cardiovascular) and mortality (diabetes-related, cardiovascular, all-cause mortality)-will be performed as statistical validation. The proposed EHR-based approach will quantify the T2DM severity for primary care performance management and inform the methodology for measuring severity of other primary care-managed chronic conditions. We anticipate that the developed algorithm will be a practical tool for practitioners, aid clinical management decision-making, inform stratified medicine, support future clinical trials and contribute to more effective service planning and policy-making. Ethics and dissemination The study protocol was approved by the Independent Scientific Advisory Committee. Some data were presented at the National Institute for Health Research School for Primary Care Research Showcase, September 2017, Oxford, UK and the Diabetes UK Professional Conference March 2018, London, UK. The study findings will be disseminated in relevant academic conferences and peer-reviewed journals.