Silicon has great potential as an anode material for high-performance lithium-ion batteries (LIBs). This work reports a facile, high-yield, and scalable approach to prepare nanoporous silicon, in which commercial magnesium silicide (Mg2Si) reacted with the acidic ionic liquid at 100 °C and ambient pressure. The obtained silicon consists of a crystalline, porous structure with a BET surface area of 450 m2/g and pore size of 1.27 nm. When coated with the nitrogen-doped carbon layer and applied as LIB anode, the obtained nanoporous silicon-carbon composites exhibit a high initial Coulombic efficiency of 72.9% and possess a specific capacity of 1000 mA h g−1 at 1 A g−1 after 100 cycles. This preparation method does not involve high temperature and pressure vessels and can be easily applied for mass production of nanoporous silicon materials for lithium-ion battery or for other applications.