Determining 2,4,6-trinitrotoluene (TNT) in aqueous solution is of great importance for public security, environment, and public health protection. The covalent organic framework (COF) based fluoresce probes are still of interest in developing the sensor-based detection systems for TNT. So, a novel fluorescence solid-state probe based on a melamine-based COF (SNW1)for TNT detection was established for the first time. A Fluorine-doped tin oxide (FTO) was used as a substrate, and COF was electrospray deposited onto its surface (SNW1@FTO). The effective parameters including the coating time, absorption, and desorption were optimized. Upon the addition of TNT, the fluorescence of SNW1 was quenched due to an acceptor–donor interaction. Therefore, the SNW1@FTO could detect TNT as a “Turn-off” sensor. The SNW1 probe showed good selectivity and sensitivity toward TNT in the range of 5 to 700 µmol L− 1. Finally, this sensor was employed to quantify TNT in real samples with satisfactory results