During the detection of formaldehyde, sensitivity and selectivity is still a challenging issue for most reported gas sensors. Herein, an alternative formaldehyde chemosensor that is based on porous ZnSnO3 nanocubes was synthesized. The products are characterized by XRD, SEM, TEM (HRTEM), XPS, PL measurements and N2 adsorption-desorption. The size of the ZnSnO3 nanocubes is about 100 nm and the corresponding specific surface area is 70.001 m2 g-1. A gas sensor based on these porous ZnSnO3 nanocubes shows high sensitivity and selectivity to formaldehyde. The porous ZnSnO3 nanocube sensor could detect 50 ppm formaldehyde at about 210 °C with a response value of 21.2, which is twice as much as ethanol, and 3 times that of the other five gases. Moreover, the response of the sensor had an acceptable change after a pulse test for 90 days. The sensor can detect formaldehyde with a minimum concentration of 1 ppm, and it has a good linear relationship between 1-50 ppm formaldehyde. The gas sensor based on porous ZnSnO3 nanocubes can be utilized as a promising candidate for a practical detector of formaldehyde due to its high gas response and excellent selectivity.