Congenital heart disease (CHD) is the most common birth defect, and up to 50% of infants with CHD require cardiovascular surgery early in life. Current clinical practice often involves thymus resection during cardiac surgery, detrimentally affecting T-cell immunity. However, epidemiological data indicate that CHD patients face an elevated risk for infections and immune-mediated diseases, independent of thymectomy. Hence, we examined whether the cardiac defect impacts thymus function in individuals with CHD. We investigated thymocyte development in 58 infants categorized by CHD complexity. To assess the relationship between CHD complexity and thymic function, we analyzed T-cell development, thymic output, and biomarkers linked to cardiac defects, stress, or inflammation. Patients with highly complex CHD exhibit thymic atrophy, resulting in low frequencies of recent thymic emigrants in peripheral blood, even prior to thymectomy. Elevated plasma cortisol levels were detected in all CHD patients, while high NT-proBNP and IL-6 levels were associated with thymic atrophy. Our findings reveal an association between complex CHD and thymic atrophy, resulting in reduced thymic output. Consequently, thymus preservation during cardiovascular surgery could significantly enhance immune function and the long-term health of CHD patients.