Coral reef ecosystems in the South China Sea are one of the globally important marine biodiversity hotspots. However, there are few studies on nematode biodiversity in coral reef sediments. Here, we assessed nematode biodiversity in coral reef sediments in the South China Sea using eDNA metabarcoding. Eight sampling stations were set up in the region north of the South China Sea Basin (Xisha and Zhongsha Islands) and south of it (Nansha Islands), respectively. We also compared and analysed the nematode biodiversity and community structure in different regions, as well as the effects of environmental factors on the community structure. The results showed that a total of 503 operational taxonomic units (OTUs) were detected in 16 sediment samples. The nematodes identified belong to two classes, 10 orders, 37 families, 51 genera and 61 species, and all of them were Enoplea and Chromadorea, except for the unidentified taxa, which accounted for 97.26% of the total abundance. The analyses showed that the northern region had higher nematode abundance and diversity relative to the southern region. However, there was no significant difference in the nematode community structure between the two regions, which was less affected by geographic location. Similarly, environmental factors (total nitrogen, total phosphorus, copper, zinc, cadmium, lead and arsenic) have an effect on the abundance of specific nematode groups but not on the overall community structure. In summary, this study initially reveals the composition and diversity of nematode communities in coral reef sediments in the South China Sea and provides an important reference for further in-depth study of the South China Sea ecosystem.