By carrying out first-principles calculations, we studied the charge density waves (CDWs) in monolayer/few-layer $H\text{\ensuremath{-}}{\mathrm{NbS}}_{2}$. For monolayer ${\mathrm{NbS}}_{2}$, unstable phonon modes are found to develop at the $2/3\mathrm{\ensuremath{\Gamma}}\mathrm{M}$ point and its symmetric points in the whole Brillouin zone. By displacing the atoms along the unstable mode, a new dynamically stable $3\ifmmode\times\else\texttimes\fi{}3$ structure with lower total energy is obtained, which corresponds well to the experimentally observed $3\ifmmode\times\else\texttimes\fi{}3$ CDW phase. The symmetries are broken in the $3\ifmmode\times\else\texttimes\fi{}3$ CDW phase, leading to gap opening and anisotropic properties. The $3\ifmmode\times\else\texttimes\fi{}3$ CDW phase of ${\mathrm{NbS}}_{2}$ is found to be stable with respect to small strains. In comparison with ${\mathrm{NbSe}}_{2}$, it is found that the Se atoms are much more active in vibration than the S atoms, resulting in the different CDW behaviors in these two very similar materials. We explored the CDW phase tuning by electron doping, and a sequence of CDW phase transitions from $3\ifmmode\times\else\texttimes\fi{}3$ to $2\ifmmode\times\else\texttimes\fi{}2$ and to $4\ensuremath{\surd}3\ifmmode\times\else\texttimes\fi{}4\ensuremath{\surd}3$ is found. The doping-dependent CDW phase provides insight into the inconsistent observation of CDW phases in ${\mathrm{NbS}}_{2}$/graphene and ${\mathrm{NbS}}_{2}$/Au(111) based on the difference in substrate charge doping. We further investigated the CDW phases of the bilayer and trilayer ${\mathrm{NbS}}_{2}$. With the decrease of the temperature, a series of instabilities occur in the phonon spectrum of bilayer ${\mathrm{NbS}}_{2}$, which correspond to $2\ifmmode\times\else\texttimes\fi{}2, 3\ifmmode\times\else\texttimes\fi{}3$, and $4\ifmmode\times\else\texttimes\fi{}4$ CDW phases. For trilayer ${\mathrm{NbS}}_{2}$, in contrast, only a $2\ifmmode\times\else\texttimes\fi{}2$ CDW phase is found, whereas the $3\ifmmode\times\else\texttimes\fi{}3$ CDW phase, which exists in monolayer and bilayer, is not manifested even at ultralow temperature. The layer-dependent CDW phases indicate significant effects of interlayer interactions.