Background and objective National patient registers are valuable in epidemiological studies. To ensure high-quality data for studies of irritable bowel syndrome (IBS), this study aimed to validate the ICD-10 code for IBS in the Swedish National Patient Register. Methods The positive predictive values (PPV) for IBS defined by the Rome criteria were calculated based on a review of medical records of randomly selected individuals with a first-ever diagnostic listing of IBS in the Swedish National Patient register in the year 2005 (Rome II criteria) or 2010 (Rome III criteria). Key results 340 medical records were reviewed (172 from 2005 and 168 from 2010). The majority of patients were females (74%), and the mean age was 42 years. IBS used in any type of department had a PPV of 76% (95% confidence interval 71–80%), which increased to 80% (76–84%) when we included individuals likely to have IBS but where information about some aspects of the Rome criteria was lacking in the medical record. Two highly specialized gastroenterological departments had the best PPV, 96%, while departments of internal medicine in general had a PPV of 82% (80–95%). The PPV for the IBS subtype was 62% (55–67%). The PPVs were not significantly different comparing the two time periods investigated. Conclusion and inferences The validity of a register-based definition of IBS in the Swedish National Patient register is high and can be used to identify patients with IBS in observational research. The data source, i.e., type of hospital and department, influences reliability.