As an antineoplastic drug, methotrexate (MTX) is widely applied in cancer therapies; however it has potentially toxic activity, and thus the qualitative and quantitative determination of MTX is of great significance. In this paper, by using dopamine synchronously as a carbon and N source, N-doped hollow nanocarbon sphere (NHNC) hybrids were prepared via a simple self-polymerization method and used to construct a new electrochemical sensor for MTX. The prepared NHNC exhibits a uniform hollow nanostructure with high conductivity and electrocatalytic properties as well as large adsorption capacity and surface area, which are the key factors for improving the sensor sensitivity of MTX. For achieving highly sensitive determination of MTX, various conditions were optimized, and the final results show that the NHNC modified electrode has excellent sensing responses for MTX, and it has a wide linear range from 0.05 to 14.0 μM coupled with a low detection limit of 0.01 μM. Finally, studies on the reproducibility, stability and selectivity of the NHNC modified electrode show that the corresponding results are satisfactory.