We characterize experimentally and theoretically the collective electronic excitations in two prototypical layered transition-metal dichalcogenides, NbSe2 and Cu0.2NbS2. The energy- and momentum-dependent dynamical structure factor was measured by inelastic x-ray scattering (IXS) spectroscopy and simulated by time-dependent density-functional theory. We find good agreement between theory and experiment, provided that Nb semicore states are taken into account together with crystal local-field effects. Both materials have very similar spectra, characterized by two main plasmons at 9 and 23 eV, which we show to both have π +σ character on the basis of a detailed analysis of the band structure. Finally, we discuss the role of the layer anisotropy in the dispersion of these plasmons.