Questioning basic assumptions about the structure of space and time has greatly enhanced our understanding of nature. State-of-the-art atomic clocks1,2,3 make it possible to precisely test fundamental symmetry properties of spacetime and search for physics beyond the standard model at low energies of just a few electronvolts4. Modern tests of Einstein’s theory of relativity try to measure so-far-undetected violations of Lorentz symmetry5; accurately comparing the frequencies of optical clocks is a promising route to further improving such tests6. Here we experimentally demonstrate agreement between two single-ion optical clocks at the 10−18 level, directly validating their uncertainty budgets, over a six-month comparison period. The ytterbium ions of the two clocks are confined in separate ion traps with quantization axes aligned along non-parallel directions. Hypothetical Lorentz symmetry violations5,6,7 would lead to periodic modulations of the frequency offset as the Earth rotates and orbits the Sun. From the absence of such modulations at the 10−19 level we deduce stringent limits of the order of 10−21 on Lorentz symmetry violation parameters for electrons, improving previous limits8,9,10 by two orders of magnitude. Such levels of precision will be essential for low-energy tests of future quantum gravity theories describing dynamics at the Planck scale4, which are expected to predict the magnitude of residual symmetry violations.