In this study, the in-situ conversion of the synthesized Co-Al layered double hydroxide (Co-Al LDH) nanosheets to three dimensional hierarchical zeolitic imidazolate framework-67 (3D HZIF-67) was pre- sented as a cost-effective, highly efficient, flexible and robust sorbent to carry out the microextraction process. In the first stage, the anodized aluminum foil was prepared electrochemically. Then, the Co-Al LDH precursor was constructed on the surface of the previously-prepared anodized Al foil applying in- situ formation approach. The procedure is followed by the conversion of the prepared Co-Al LDH film to 3D HZIF-67 film via a facile solvothermal method without adding cobalt salt. The in-situ prepared 3D HZIF-67-anodized Al was used for the thin film microextraction (TFME) of caffeine. The effective factors in TFME procedure were investigated and optimized through applying Central Composite Design (CCD). In the obtained optimal condition, the calibration curves for TFME-HPLC-UV of caffeine were linear in the range of 1–200 μg L −1 with the coefficient of determination (r 2 ) higher than 0.9915. The limits of detection were 0.33 and 0.38 μg L −1 , in water and urine matrices, respectively. Moreover, the enrichment factors (EFs) and absolute recoveries (%AR) were also calculated as 173–198 and 57.1%-65.3%, respectively. The inter-day relative standard deviations (RSDs) were evaluated as the method precision for 20 and 200 μg L −1 of spiked sample and were between 4.9–6.1%. The repeatability of the preparation step was investigated as batch-to-batch reproducibility and it was found to be 4.9%; as a result, the reproducibil- ity of the presented film was approved. Finally, the proposed method was utilized to determine caffeine (as the model analyte) from different types of real samples including urine, coffee, beverage (Pepsi) and shampoo. The obtained recoveries (higher than 88%) confirmed the capability of the method for real sam- ple analysis.