Spectral projectors of Hermitian matrices play a key role in many applications, and especially in electronic structure computations. Linear scaling methods for gapped systems are based on the fact that these special matrix functions are localized, which means that the entries decay exponentially away from the main diagonal or with respect to more general sparsity patterns. The relation with the sign function together with an integral representation is used to obtain new decay bounds, which turn out to be optimal in an asymptotic sense. The influence of isolated eigenvalues in the spectrum on the decay properties is also investigated and a superexponential behaviour is predicted.