Dark matter halos are the fundamental building blocks of cosmic large-scale structure. Their density structure contains key information about cosmology and the nature of dark matter. Numerical simulations have shown that the density profiles of halos have a remarkably self-similar form across halos of very different masses and across a large variety of cosmological models. Due to the lack of consensus on a theoretical explanation for the origin of these ‘universal’ density profiles, they are typically modeled using empirical fitting formulae. I will show how interpretable machine learning frameworks can provide new physical insights into halo density profiles. I will present a neural network model that is able to reproduce the known variations that are encapsulated by previous empirical approaches. The network goes further and discovers an additional factor of variation in the outer profile, related to the infall of dark matter (also known as the ‘splashback’ effect). I will also present a different machine-learning framework, that is able to identify the most relevant information in the initial conditions and in the halos’ mass assembly history to predict the final profiles. This work makes progress toward a broader goal of extracting knowledge from machine-learning models about the underlying physics of cosmological structure formation.