Rayleigh waves are generated along the free surface and their propagation can be strongly influenced by surface topography. Modeling of Rayleigh waves in the near surface in the presence of topography is fundamental to the study of surface waves in environmental and engineering geophysics. For simulation of Rayleigh waves, the traction-free boundary condition needs to be satisfied on the free surface. A vacuum formulation naturally incorporates surface topography in finite-difference (FD) modeling by treating the surface grid nodes as the internal grid nodes. However, the conventional vacuum formulation does not completely fulfill the free-surface boundary condition and becomes unstable for modeling using high-order FD operators. We developed a stable vacuum formulation that fully satisfies the free-surface boundary condition by choosing an appropriate combination of the staggered-grid form and a parameter-averaging scheme. The elastic parameters on the topographic free surface are updated with exactly the same treatment as internal grid nodes. The improved vacuum formulation can accurately and stably simulate Rayleigh waves along the topographic surface for homogeneous and heterogeneous elastic models with high Poisson’s ratios (). This method requires fewer grid points per wavelength than the stress-image-based methods. Internal discontinuities in a model can be handled without modification of the algorithm. Only minor changes are required to implement the improved vacuum formulation in existing 2D FD modeling codes.