This paper presents results for four types of morphology-controlled two-dimensional cobalt based tetrakis (4-carboxyphenyl) porphyrin metal-organic frameworks (2D Co-TCPP MOFs) with different catalytic properties for nitrite, and an electrochemical sensor was fabricated by the Co-TCPP MOF with superior catalytic properties. The sensor exhibited a high sensitivity of 311.3 μg/g, an extra low detection limit (LOD) of 0.03 μM, and a wide linear range of 0.1–375 μM, which was applied successfully for nitrite detection in water, milk and sausage. Moreover, density functional theory (DFT) calculations were used to establish the sensing method, the adsorption structures of nitrite on the surface of Co-TCPP MOF were built and the electrocatalytic mechanism was confirmed. The results explained why the sensor fabricated by a single Co-TCPP MOF exhibited equal or better performance than reported sensors fabricated by composite materials based on a combination of theory and experiment. This work reported a universal electrochemical sensing method for nitrite detection in food based on a single morphology-controlled 2D TCPP MOF, which provided a new and valuable strategy for establishing an efficient food safety determination method guided by theoretical calculations.