[en] The inclusion of dietary fiber (DF) in diets has been suggested as a way to reduce ammonia emission in pig barns because it contributes to a shift in N excretion from urine to feces due to enhanced bacterial growth in the intestines. This study compared an in vitro method to measure bacterial protein synthesis during fermentation to in vivo N excretion shift induced by diets differing in DF concentrations and solubility. The first experiment measured the effect of graded concentrations of sugar beet pulp (SBP; 0, 10, 20 and 30%) in corn-soybean meal-based diets on in vivo N excretion partitioning between urine and feces. A second experiment investigated the replacement of SBP, rich in soluble DF, by oat hulls (OH), rich in insoluble DF (20:0; 10.5:10.5; 0:22%, respectively). In parallel, the fermentation characteristics of the dietary carbohydrates not digested in the small intestine was evaluated in an in vitro gas test, based on their incubation with colonic microbiota, using a mineral buffer solution enriched with 15N. The N originating from the buffer solution incorporated into the bacterial proteins (BNI) was measured when half of the final gas volume was produced (T/2: 8.5 to 14.5 h of fermentation) and after 72 h of fermentation. Short-chain fatty acids (SCFA) were determined in the liquid phase. In the first experiment, the inclusion of SBP linearly decreased urinary N excretion from 0.285 to 0.215 g N excreted in urine per g N ingested and urinary-N:fecal–N excretion ratio from 2.171 to 1.177 (P < 0.01). In the second experiment, the substitution of SBP by OH linearly increased urinary-N:fecal–N excretion ratio (P = 0.009). Unlike SCFA production, BNI was greater at T/2 than at 72 h of fermentation. Sugar beet pulp enhanced BNI linearly (P < 0.001): 2.01, 2.06 and 2.35 mg g-1 diet with 10, 20 and 30% SBP, respectively, as compared to 1.51 mg for the control diet. The substitution of SBP by OH decreased BNI (P < 0.01). With the exception of final gas production, all in vitro kinetics characteristics and BNI were correlated to in vivo N excretion parameters and regression equations for the prediction of N excretion pathways from in vitro data were identified. Even if the presence of resistant starch in the diet might alter the composition of the fibrous residue that is fermented, it can be concluded that the in vitro method is a possible useful tool for the formulation of diets reducing the effects of pig production on the environment.