Diabetic ketoacidosis (DKA) is the most common acute hyperglycaemic emergency in people with diabetes mellitus. A diagnosis of DKA is confirmed when all of the three criteria are present — ‘D’, either elevated blood glucose levels or a family history of diabetes mellitus; ‘K’, the presence of high urinary or blood ketoacids; and ‘A’, a high anion gap metabolic acidosis. Early diagnosis and management are paramount to improve patient outcomes. The mainstays of treatment include restoration of circulating volume, insulin therapy, electrolyte replacement and treatment of any underlying precipitating event. Without optimal treatment, DKA remains a condition with appreciable, although largely preventable, morbidity and mortality. In this Primer, we discuss the epidemiology, pathogenesis, risk factors and diagnosis of DKA and provide practical recommendations for the management of DKA in adults and children.