We show that a function f of bounded variation satisfies that Var(Mf) is less than or equal to C Var(f) for some absolute constant C, where Mf is the centered Hardy-Littlewood maximal function of f. This allows us to answer a question of Hajlasz and Onninen in the one-dimensional case.