Synthesis of imidazolidin-2-one-4-carboxylate and of (tetrahydro)pyrimidin-2-one-5-carboxylate via an efficient modification of the Hofmann rearrangement.