A high selective and two-photon fluorogenic probe (TPNF) for detecting formaldehyde was developed. A time-dependent density functional theory calculation was performed to demonstrate the turn on mechanism of the probe. HeLa cells and zebrafish larvae imaging experiments reveal that TPNF is a promising tool in the further biomedical research.