Despite the wide applicability of oxynitrides from photocatalysis to refractory coatings, our understanding of the materials has been limited in terms of their thermodynamics. The configurational entropy via randomly mixed O/N or via cation vacancies are known to stabilize oxynitrides, despite the positive formation enthalpies. Here, using tin oxynitrides as a model system, we show by ab initio computations that oxynitrides in seemingly charge-unbalanced composition stabilize by forming pernitrides among metal-(O,N)6 octahedra. The nitrogen pernitride dimer, =(N-N)=, results in the effective charge of -4, facilitating the formation of nitrogen-rich oxynitrides. We report that the dimer forms only in structures with corner-sharing octahedra, since the N-N bond formation requires sufficient rotational degrees of freedom among the octahedra. X-ray photoemission spectra of the synthesized tin oxynitride films reveal two distinct nitrogen bonding environments, confirming the computation results. This work opens the search space for a novel kind of oxynitrides stabilized by N dimer formation, with specific structural selection rules.