Silkworm pupae as widely consumed insect products are good biosources of protein and micronutrients. Silkworm rearing throughout the year can be achieved by feeding them an artificial diet instead of native plants, facilitating extensive pupa production. However, artificial diets are prone to spoilage caused by bacterial contamination. Here, we evaluated the antiseptic effect of ethylparaben (EP, chemical preservative) and medium-chain fatty acids (MCFA, natural preservative) in a silkworm artificial diet. Results showed that both preservatives effectively inhibited pathogenic bacterial growth. Furthermore, the addition of EP or MCFA did not negatively impact the production capacity of silkworms and the homeostasis of gut microbiota. However, the expression of genes involved in detoxification such as Ugt2, and immune response such as Cecropin B, were upregulated after EP consumption. Therefore, natural preservative MCFA emerges as a suitable option from a safety perspective. These findings highlight future directions for improving insect artificial diet formulation.