We study the stochastic formalism of inflation beyond the usual slow-roll approximation. We verify that the assumptions on which the stochastic formalism relies still hold even far from the slow-roll attractor. This includes demonstrating the validity of the separate universe approach to evolving long-wavelength scalar field perturbations beyond slow roll. We also explain that, in general, there is a gauge correction to the amplitude of the stochastic noise. This is because the amplitude is usually calculated in the spatially-flat gauge, while the number of e-folds is used as the time variable (hence one works in the uniform-$N$ gauge) in the Langevin equations. We show that these corrections vanish in the slow-roll limit, but we also explain how to calculate them in general. We compute them in difference cases, including ultra-slow roll and the Starobinsky model that interpolates between slow roll and ultra-slow roll, and find the corrections to be negligible in practice. This confirms the validity of the stochastic formalism for studying quantum backreaction effects in the very early universe beyond slow roll.