Wavefront correction is of great significance in a variety of fields but still faces many challenges. Here we propose an all-optical wavefront calibration routine based on a diffractive optical neural network (DONN), which consists of pre-trained multi-layer phase modulation pixel arrays. This enables real-time correction without a wavefront sensor. The optimized DONN is capable of compensating unknown wavefront distortions without task-specific retraining, and it demonstrates broad generalization. Our results promise rapid optical system calibration and establish a broadly applicable and almost all-optical wavefront correction approach with DONN-in-the-loop.