In this work, we proposed a new method based on carbon dots (named m-CDs) for selective and efficient detection of nitrite (NO2–), which was based on the interaction between the amine group of m-CDs and NO2– via a diazo reaction that produced diazonium salts and induced the fluorescence quenching of m-CDs. The concentration of NO2– shows a good linear relationship with a quenched fluorescence intensity from 0.063 to 2.0 μM (R2 = 0.996) with a detection limit of 0.018 μM. In addition, a ratiometric fluorescence probe (m-CDs@[Ru(bpy)3]2+) was constructed via electrostatic interaction by introducing Ru(bpy)3Cl2·6H2O as an internal reference fluorescent reagent. Interestingly, a transition of the fluorescent color of the ratiometric probe from cyan to red could be visually observed upon increasing the concentration of NO2–. Based on these findings, a ratiometric fluorescent-based portable agarose hydrogel test kit was fabricated and applied for on-spot assessment of NO2– content within 10 min. As far as we know, this is the first ratiometric fluorescent sensor for visual detection of NO2–. It has broad application prospects in environmental monitoring and food safety assessment.