This study evaluated the effect of different medium-chain to long-chain fatty acid (MCFA:LCFA, M:L) ratios on growth performance, intestinal function, antioxidant capacity and gut microbiota in piglets. A total of 250 piglets were randomly assigned to five groups with five replicates, each containing ten pigs. The diets, containing varying amounts of MCFA-rich coconut oil and LCFA-rich soyabean oil, resulted in M:L ratios of 0, 2·1, 4·2, 8·8 and 33·8 %. Results showed that both final body weight and average daily weight gain increased as the M:L ratio increased (P < 0·05), while the 8·8 % M:L ratio diet exhibited the lowest feed:gain ratio (P < 0·05). As the M:L ratio increased, the contents of superoxide dismutase and glutathione peroxidase were increased, and MDA was decreased in serum (P < 0·05). The 8·8 and 33·8 % M:L diets improved ileal and jejunal morphology (P < 0·05), as indicated by greater villus height and villus height:crypt depth ratios. Furthermore, increasing M:L ratios from 0 to 33·8 % increased expression of tight junction proteins occludin and ZO-1 in the jejunum (P < 0·05). The 33·8 % M:L ratio reduced microbial α-diversity (P < 0·05), while 8·8 % M:L diet significantly increased the abundance of beneficial bacteria (e.g. Lactobacilli, Prevotella) and decreased harmful bacteria (e.g. Escherichia-Shigella, Enterococcus) in the cecum (P < 0·05). In summary, our study found that 8·8 % of dietary M:L ratios significantly improved growth performance, likely through modulating intestinal function, antioxidant activity and gut microbial composition.