Abstract N and S co-doped carbon dots (N, S-CDs) were synthesized and used as corrosion inhibitors for the first time in this study. The inhibition performance of N, S-CDs for carbon steel in CO2-saturated NaCl solution was investigated. Results showed that N, S-CDs can effectively protect carbon steel from corrosion and the inhibition efficiency increases as the concentration of N, S-CDs increases, reaching 93% at 50 mg/L. Even at the low concentration, such as 10 mg/L N, S-CDs, the corrosion current density reduces from 1.472 × 10−4 A·cm−2 in the blank condition to 2.99 × 10−5 A·cm−2 after 12 h immersion. N, S-CDs can adsorb on carbon steel through their functional groups and nanoparticles made up of N, S-CDs can form a hydrophobic film on the metal surface, whose thickness was about 40 nm. A theoretical model is established to describe the inhibition mechanism of N, S-CDs.