Ratchets are devices that are able to rectify an otherwise oscillatory behavior by exploiting an asymmetry of the system. In rocking ratchets, the asymmetry is induced through a proper choice of external forces and modulations of nonlinear symmetric potentials. The ratchet currents thus obtained in systems as different as semiconductors, Josephson junctions, optical lattices, or ferrofluids show a set of universal features. A satisfactory explanation for them has challenged theorists for decades, and so far, we still lack a general theory of this phenomenon. Here, we provide such a theory by exploring-through functional analysis-the constraints that the simple assumption of time-shift invariance of the ratchet current imposes on its dependence on the external drivings. Because the derivation is based on so general a principle, the resulting expression is valid irrespective of the details and the nature of the physical systems to which it is applied, and of whether they are classical, quantum, or stochastic. The theory also explains deviations observed from universality under special conditions and allows us to make predictions of phenomena not yet observed in any experiment or simulation.