The phase transition and structural evolution of KN3 are systematically studied using first-principles density functional (DFT) methods and the particle swarm optimization (PSO) structure search algorithm under pressures up to 400 GPa. For the first time, we identify three stable phases with , and structure at pressures of 15.7, 41.4 and 298.6 GPa. The analysis of the crystal structures of three new predicted phases reveals that the transition of N3− ions goes from linear molecules to benzene-like rings and then to polymer chains induced by pressure. The study of atomic and electronic structures of three predicted phases reveals that the structural changes are accompanied and driven by the change of atomic orbital hybridization, first from sp to sp2, and then from sp2 to sp3. Our result provides a new view of the pressure-induced polymerization process of metal azides.