We apply principal component analysis (PCA) to a set of electrical output signals from a commercially available superconducting nanowire single-photon detector (SNSPD) to investigate their photon-number-resolving capability. We find that the rising edge as well as the amplitude of the electrical signal have the most dependence on photon number. Accurately measuring the rising edge while simultaneously measuring the voltage of the pulse amplitude maximizes the photon-number resolution of SNSPDs. Using an optimal basis of principal components, we show unambiguous discrimination between one- and two-photon events, as well as partial resolution up to five photons. This expands the use case of SNSPDs to photon-counting experiments, without the need of detector multiplexing architectures. Published by the American Physical Society 2024