Iron can enter the electron-rich cavities of graphitic carbon nitride (g-C3N4). On account of this phenomenon, Fe-doped g-C3N4 (Fe-g-C3N4) was prepared as a peroxidase mimetic by using one-step pyrolysis of urea and FeCl3·6H2O. Compared to g-C3N4, Fe-g-C3N4 has a large specific surface area due to the presence of mesopores and cracks, a smaller band gap, and a high loading of Fe in its structure. Thus, Fe-g-C3N4 exhibits greater peroxidase activity with a more obvious color change when using 3,3',5,5'-tetramethylbenzidine (TMB) as a substrate in the presence of hydrogen peroxide (H2O2). The color of a mixture of TMB and Fe-g-C3N4 gradually deepens with increasing concentrations of H2O2. Accordingly, a rapid, sensitive, and low-cost colorimetric assay for the detection of H2O2 was developed. After optimization, this method boasts a wide linear dynamic range for H2O2 detection from 0.005 to 400 μM (r2 = 0.9971) with a detection limit of 0.005 μM. Because H2O2 is a main product of glucose oxidation by glucose oxidase (GOx), a colorimetric assay for glucose detection was also realized, with a linear dynamic range of 1-1000 μM (r2 = 0.9996) and a detection limit of 0.5 μM. These assays were applied to the quantitative detection of H2O2 in milk and glucose in human serum, respectively.