Characterizing the metabolic profile of a microbial community is crucial for understanding its biological function and its impact on the host or environment. Metabolomics experiments directly measuring these profiles are difficult and expensive, whereas sequencing methods quantifying the species composition of microbial communities are well developed and relatively cost-effective. Computational methods that are capable of predicting metabolomic profiles from microbial compositions can save considerable efforts needed for metabolomic profiling experimentally. Yet, despite existing efforts, we still lack a computational method with high prediction power, general applicability and great interpretability. Here we develop a method called metabolomic profile predictor using neural ordinary differential equations (mNODE), based on a state-of-the-art family of deep neural network models. We show compelling evidence that mNODE outperforms existing methods in predicting the metabolomic profiles of human microbiomes and several environmental microbiomes. Moreover, in the case of human gut microbiomes, mNODE can naturally incorporate dietary information to further enhance the prediction of metabolomic profiles. Furthermore, susceptibility analysis of mNODE enables us to reveal microbe–metabolite interactions, which can be validated using both synthetic and real data. The results demonstrate that mNODE is a powerful tool to investigate the microbiome–diet–metabolome relationship, facilitating future research on precision nutrition.