© The Royal Society of Chemistry 2018. The development of devices for sensing and monitoring CO2 levels is crucial for many fields such as food packaging and for human safety indoors. Herein the fabrication of an optical CO2 sensor by integration of a metal-organic framework (MOF) onto bimodal optical waveguides is reported. This sensor is constructed via self-assembly of a transparent film of zeolitic imidazolate framework-8 (ZIF-8) nanoparticles (size: 32 ± 5 nm) on the waveguides. The nanoZIF-8-based sensor exhibits a broad linear response, with limits of detection of 3130 ppm at room temperature and 774 ppm at 278 K. Furthermore, it is robust, selective, fast and reusable, and can be stored under humid conditions with no loss in performance.