Background and AimsPyoderma gangrenosum (PG) is a neutrophilic inflammatory dermatosis that can be idiopathic or associated with other diseases. The aim was to analyze the epidemiological and clinical characteristics, temporal trends, risk factors for poor prognosis, and admission costs associated with PG in Spain.MethodsWe conducted a retrospective study, based on the Hospital Discharge Registry of the Spanish National Health System in Spain from 1999 to 2021.ResultsOf 82,161,670 admissions during the study period, 4901 were for PG (hospitalization rate of 59.7/1,000,000 admissions). PG hospitalizations increased from 28.8/1,00,000 in 1999 to 91.9/1,000,000 in 2021. PG was a primary cause of admission in 60.5% of cases, and 58.4% of patients were women. The main PG‐related comorbidities were inflammatory bowel disease (15.7%) and neoplasms (10%). There was a significant increase over the years in admissions for inflammatory bowel disease, monoclonal gammopathy of undetermined significance, and lymphoma, as well as an increase in diseases unrelated to PG, such as hypertension, diabetes, and chronic kidney disease. The hospital mortality rate was 5.6%. Death was associated with PG being a primary diagnosis, older age, leukemia, neoplasms, diabetes, and chronic kidney disease. The cost of treatment increased over the years and was higher in older people.ConclusionPG cases in the inpatient setting in Spain over the past 23 years make up a tiny proportion of all hospital admissions, although the rate of hospitalization for PG has increased in the last two decades.