The invention discloses a porphyrin cage compound, and a preparation method and application thereof. The invention provides the porphyrin cage compound. A structural formula is shown as a formula (I). The preparation method comprises the following step of: performing 1,3-dipole cycloaddition reaction of a compound shown as a formula (II) and a compound shown as a formula (III) under the catalysis of cuprous iodide and an alkaline compound to obtain the porphyrin cage compound. According to the preparation method, the process is simple and convenient, the reaction yield is relatively high, polynitrogen anions can be identified efficiently, and the detection sensitivity is high, for example, the lower limit of detection concentration of nitrine anions in dichloromethane can reach 10 ppm; the selectivity is high, for example, the nitrine anions do not have response to other anions such as F<->, Cl<->, Br<->, I<->, SO4<2->, HSO4<->, PO4<3->, HPO4<2->, H2PO4<->, NO3<-> and the like; and a detection method can be performed by two methods, namely a nuclear magnetic resonance hydrogen spectrum and an ultraviolet spectrum, and even the nitrine anions can be determined directly and qualitatively by using naked eyes according to the change of solution colors.