OBJECTIVES Pectus excavatum (PE) is often regarded as a cosmetic disease, while its effect on cardiac function is under debate. Data regarding cardiac function before and after surgical correction of PE are limited. We aimed to assess the impact of surgical correction of PE on cardiac function by cardiovascular magnetic resonance (CMR). METHODS CMR at 1.5 T was performed in 38 patients (mean age 21 ± 8.3; 31 men) before and after surgical correction to evaluate thoracic morphology, indices and its relation to three-dimensional left and right ventricular cardiac function. RESULTS Surgery was successful in all patients as shown by the Haller Index ratio of maximum transverse diameter of the chest wall and minimum sternovertebral distance [pre: 9.64 (95% CI 8.18–11.11) vs post: 3.0 (2.84–3.16), P < 0.0001]. Right ventricular ejection fraction (RVEF) was reduced before surgery and improved significantly at the 1-year follow-up [pre: 45.7% (43.9–47.4%) vs 48.3% (46.9–49.5%), P = 0.0004]. Left ventricular ejection fraction was normal before surgery, but showed a further improvement after 1 year [pre: 61.0% (59.3–62.7%) vs 62.7% (61.3–64.2%), P = 0.0165]. Cardiac compression and the asymmetry index changed directly after surgery and were stable at the 1-year follow-up [3.93 (3.53–4.33) vs 2.08 (1.98–2.19) and 2.36 (2.12–2.59) vs 1.38 (1.33–1.44), respectively; P < 0.0001 for both]. None of the obtained thoracic indices were predictors of the improvement of cardiac function. A reduced preoperative RVEF was predictive of RVEF improvement. CONCLUSIONS PE is associated with reduced RVEF, which improves after surgical correction. CMR has the capability of offering additional information prior to surgical correction.