We present a theory of thermal grooving, i.e. surface motion due to surface diffusion, based solely on geometrical and energetic arguments and a variational approach involving a thermodynamic extremal principle. The theory is derived for a fully three-dimensional setting. All interface and contact conditions at junction lines and points of the material aggregate are derived rigorously and without ambiguity. A finite element implementation of the model is employed. Numerical examples are presented and compared with experimental results from the literature. (C) 2017 Acta Materialia Inc. Published by Elsevier Ltd. All rights reserved.