Abstract The numerical approximation of an optimal control problem governed by a semilinear parabolic equation and constrained by a bound on the spatial $L^1$-norm of the control at every instant of time is studied. Spatial discretizations of the controls by piecewise constant and continuous piecewise linear functions are investigated. Under finite element approximations, the sparsity properties of the continuous solutions are preserved in a natural way using piecewise constant approximations of the control, but suitable numerical integration of the objective functional and of the constraint must be used to keep the sparsity pattern when using spatially continuous piecewise linear approximations. We also obtain error estimates and finally present some numerical examples.