An electrochemical DNA sensor that can detect human papillomavirus (HPV)-16 and HPV-18 for the early diagnosis of cervical cancer was developed by using a graphitic nano-onion/molybdenum disulfide (MoS2) nanosheet composite. The electrode surface for probing DNA chemisorption was prepared via chemical conjugation between acyl bonds on the surfaces of functionalized nanoonions and the amine groups on functionalized MoS2nanosheets. The cyclic voltammetry profile of an 1:1 nanoonion/MoS2nanosheet composite electrode had an improved rectangular shape compared to that of an MoS2nanosheet elecrode, thereby indicating the amorphous nature of the nano-onions with sp2distancing curved carbon layers that provide enhanced electronic conductivity, compared to MoS2nanosheet only. The nanoonion/MoS2sensor for the DNA detection of HPV-16 and HPV-18, respectively, was measured at high sensitivity through differential pulse voltammetry (DPV) in the presence of methylene blue (MB) as a redox indicator. The DPV current peak was lowered after probe DNA chemisorption and target DNA hybridization because the hybridized DNA induced less effective MB electrostatic intercalation due to it being double-stranded, resulting in a lower oxidation peak. The nanoonion/MoS2nanosheet composite electrodes attained higher current peaks than the MoS2nanosheet electrode, thereby indicating a greater change in the differential peak probably because the nanoonions enhanced conductive electron transfer. Notably, both of the target DNAs produced from HPV-18 and HPV-16 Siha and Hela cancer cell lines were effectively detected with high specificity. The conductivity of MoS2improved by complexation with nano-onions provides a suitable platform for electrochemical biosensors for the early diagnosis of many ailments in humans.Graphical AbstractSupplementary InformationThe online version contains supplementary material available at 10.1186/s12951-023-01948-6.