The main purpose of the present study was to assess the effect of soluble and insoluble fiber on colonic bacteria and intestinal barrier function in a piglet model. A total of 24 piglets (25 ± 1 d old; 7.50 ± 0.31 kg) were randomly allotted to 4 treatments: basal diet (control, CON), 1% insoluble dietary fiber (IDF) diet, 1% soluble dietary fiber (SDF) diet, and 0.5% insoluble fiber + 0.5% soluble dietary fiber (MDF) diet. The trial lasted 28 days. SDF-fed piglets showed a higher P<0.05 bacterial a-diversity (observed_species, chao1, and ACE) and a higher relative abundance of Proteobacteria and Actinobacteria, Solobacterium, Succinivibrio, Blautia, and Atopobium in colonic digesta than CON, IDF, and MDF groups P<0.05. At the same time, Bacteroidetes, Euryarchaeota, Phascolarctobacterium, Coprococcus_1, and Prevotella_1 were significantly increased in the IDF group when compared with CON, SDF, and MDF groups P<0.05. Furthermore, Bacteroidetes and Enterobacteriaceae, Selenomonas, Phascolarctobacterium, and AlloprevotellaP<0.05 were significantly higher in the MDF group than those in the other three groups P<0.05. SDF diet increased the concentrations of short-chain fatty acid (SCFA) in colonic digesta P<0.05 when compared with the CON group and enhanced weight index of the colon P<0.05 than the CON and IDF groups. Furthermore, compared with the CON group, SDF, IDF, and MDF diets all upregulated the mRNA expressions of claudin-1 (CLDN-1) in colonic mucosa P<0.05, SDF and IDF diets upregulated the mRNA expressions of mucin 2 (MUC2) P<0.05, SDF diet increased mRNA expressions of zonula occludens 1 (ZO-1) and occludin (OCLN), while the IDF group enhanced the secretory immunoglobulin A (sIgA) concentrations P<0.05, respectively. IDF and MDF diets decreased expressions of TNF-αP<0.05. We concluded that the influence of soluble fiber on colonic microbiota was more extensive than that of insoluble fiber. Moreover, soluble fiber could more effectively improve colonic barrier function by upregulating gene expressions of the gut barrier.