In this work, we discover the quantitative predictability of model losses regarding the mixture proportions of training data, which boils down to the data mixing laws. Our findingscover training data from two domains to multiple domains, and validation data from a single domain to unknown compositions. Using data mixing laws allows practitioners to quantitatively estimate the model performance on unseen mixture proportions before the actual training, facilitating the tuning of ideal mixture proportions. We further propose the nested use of scaling laws of training steps, model sizes, and data mixture to make predictions with only experiments at small scales, which enables the reuse of existing experiments and reduces the computation costs. Experimental results suggest that our method effectively optimizes the data mixture, which leads to better performance in pretraining and maintaining the original abilities of pretrained models in continual pretraining.