Owing to the high cost and unavailability of different analytical techniques, there is an urgent need to develop new techniques not only for detecting but also removing mercury ions in real samples. Thus, an optical chemical sensor based on the anchoring of phenanthraquinone monophenylthiosemicarbazone in a plasticized cellulose triacetate membrane was fabricated and applied to the recognition and removal of mercury ions from aqueous solutions. The synthesized optode was characterized by FT-IR, SEM, AFM, and thermal analysis. Several parameters, including the pH, temperature, contact time, washing solvent, and washing time, were optimized. Under optimal conditions, a promising optode film platform was utilized for sensing mercury ions, and the concentrations were calculated based on colorimetric analysis (Histogram, RGB) of digital images, visualization, and spectrophotometry. Also, an optical optode was used for complete adsorption of mercury ions from aqueous solutions. In addition, the regeneration of the synthesized optode was evaluated using 0.1 mol L− 1 nitric acid, which effectively removed all adsorbed mercury ions. The obtained data indicated good linearity in the sensing and adsorption of Hg2+ over a concentration range of 0.005–5000 µgL− 1 with a low limit of detection (LOD = 0.066 µgL− 1) and limit of quantification (LOQ, 0.22 µgL− 1). Furthermore, it showed good distinctions in the presence of coexisting ions, high stability (five months), good applicability, and reproducibility (RSD = 1.31%), making it a promising sensor for Hg2+ detection. On the other hand, the kinetic studies revealed that the pseudo-second-order was the best model for describing the adsorption behavior of mercury ions on the optode surface. Also, the thermodynamic parameters indicate spontaneous (ΔG0 < 0) and endothermic (ΔH0 < 0) reactions. Also, the maximum adsorption capacity was found to be 73.2 mg g− 1. Thus, the optodes were successfully applied for the detection and/or removal of Hg2+ in different real samples, including cucumber, fish, soil, and water samples, with excellent recoveries of 98.1–99.5%.