  We present the Hamiltonian formalism for $f(T)$ gravity, and prove that the
theory has $\frac{n(n-3)}{2}+1$ degrees of freedom (d.o.f.) in $n$ dimensions.
We start from a scalar-tensor action for the theory, which represents a scalar
field minimally coupled with the torsion scalar $T$ that defines the
teleparallel equivalent of general relativity (TEGR) Lagrangian. $T$ is written
as a quadratic form of the coefficients of anholonomy of the vierbein. We
obtain the primary constraints through the analysis of the structure of the
eigenvalues of the multi-index matrix involved in the definition of the
canonical momenta. The auxiliary scalar field generates one extra primary
constraint when compared with the TEGR case. The secondary constraints are the
super-Hamiltonian and supermomenta constraints, that are preserved from the
Arnowitt-Deser-Misner formulation of GR. There is a set of $\frac{n(n-1)}{2}$
primary constraints that represent the local Lorentz transformations of the
theory, which can be combined to form a set of $\frac{n(n-1)}{2}-1$ first-class
constraints, while one of them becomes second-class. This result is
irrespective of the dimension, due to the structure of the matrix of the
brackets between the constraints. The first-class canonical Hamiltonian is
modified due to this local Lorentz violation, and the only one local Lorentz
transformation that becomes second-class pairs up with the second-class
constraint $\pi \approx 0$ to remove one d.o.f. from the $n^2+1$ pairs of
canonical variables. The remaining $\frac{n(n-1)}{2}+2n-1$ primary constraints
remove the same number of d.o.f., leaving the theory with $\frac{n(n-3)}{2}+1$
d.o.f. This means that $f(T)$ gravity has only one extra d.o.f., which could be
interpreted as a scalar d.o.f.
