Tert-butylhydroquinone (TBHQ) is a widely used synthetic phenolic antioxidant found in edible oils and other fried foods. Nevertheless, the excess use of TBHQ can reduce food quality and impact public health. In this paper, we reported the synthesis of a nanocomposite consisting of carbon and nitrogen co-doped nickel oxide (NiO-N/C-700), which was used to modify a pencil graphite electrode for the sensitive detection of TBHQ. The carbon source was biochar derived from invasive species Solidago canadensis L., combined with inexpensive pencil graphite, which reduced overall cost. The as-prepared TBHQ electrochemical sensor exhibited a linear range of 0.02-200 μM, a limit of detection of 5.53 nM. In particular, this sensor can be applied for the quantitative detection of TBHQ in edible oil, fried food and crisps, achieving a satisfactory recovery rate of 99.30 %-106.40 %, promoting TBHQ detection in actual food samples.