We have studied the surface dynamics of SrTiO3 during wet etching and during subsequent high-temperature annealing. Real-time observation of the wet etching process by atomic force microscopy has made it possible to find optimal etching conditions which yield atomically smooth surfaces while avoiding the generation of etch pits. Comparison of the experimental etching rates and Monte Carlo simulations of the etching process showed that etching proceeds at different speeds depending on the local atomic-scale configuration. Similar local unit cell configuration-dependent effects influence the STO step edge dynamics during high-temperature annealing which is required to produce substrates with straight step edges and atomically smooth terraces. The combination of etching and annealing of SrTiO3 gave us an ideal substrate surface for the fabrication of Josephson tunnel junctions through atomically controlled epitaxy.