Stable compounds comprising nitrogen, sulfur, and hydrogen elements hold significant promise in hydride superconductors and astrophysical matter. Herein, we utilize a blend of structure prediction techniques and first-principles calculations to comprehensively explore the N–H–S system. We present the discovery of two ionic compounds, and , characterized by similar configurations but distinct arrangements of sulfur atoms. As the sulfur content increases, we observe a transition in the bonding pattern of sulfur-sulfur interactions from dimers to units. Furthermore, the electron transfer from to each S unit escalates from 1.04 to 1.24 . Through ab initio molecular dynamics simulations, we unveil a sequence of phase transitions encompassing solid, superionic, and liquid phases for both compounds. Notably, the high-pressure and high-temperature phase diagrams reveal that only the superionic phase of corresponds to the extreme conditions found in the interior of the Earth. Moreover, the liquid regions of both compounds encompass the isentropic lines of Neptune, Uranus, and Jupiter. These results could provide essential information for understanding the N–H–S system at high pressure and the formation models of the planets.