A surface acoustic wave (SAW) formaldehyde gas sensor was fabricated on a 42°75' ST-cut quartz substrate, with a composite sensing layer of zeolitic imidazolate framework (ZIF)-8 on polyethyleneimine (PEI)/ bacterial cellulose (BC) nanofilms. The addition of snowflake-like ZIF-8 structure on the PEI/BC sensitive film significantly improves the hydrophobicity of the SAW sensor and increases the sensor's sensitivity to formaldehyde gas. It also significantly increases the surface roughness of the sensitive film. Its hydrophobic nature prevents water molecules from entering into the internal pores of the BC film, thereby avoiding significant mass loading caused by the humidity change when the sensor is used to detect low-concentration formaldehyde gas. The Zn2+ sites at the surface of ZIF-8 improves the sensor's response to formaldehyde gas through enhancing the physical adsorptions. Experimental results show that the ZIF-8@PEI/BC SAW sensor has a response (e.g., frequency shift) of 40.3 kHz to 10 ppm formaldehyde gas at 25℃ and 30% RH. When the relative humidity was increased from 30% to 93%, the response (frequency shift) of the sensor drifts only ~5%, and there is negligible drift at a medium humidity level (~56% RH).