Bulk silicon is a poor light emitter and absorber, but its optical properties are significantly enhanced by nanostructuring. We use first-principles calculations to investigate the electronic and optical properties of nanoporous silicon. We determine and analyze the electronic structure, optical coefficients, and photovoltaic conversion efficiency as a function of pore size and spacing. Our results show that the visible-range absorption coefficient of nanoporous Si is greatly improved compared to the bulk for pore spacings and sizes on the scale of a few nanometers. The photovoltaic efficiency is improved to up to 2.7 times compared to bulk Si, and the theoretical maximum conversion efficiency reaches up to 6.3% for a thin-film nanoporous material thickness of 135 nm. Our results show that nanoporous Si is a promising material for thin-film photovoltaic applications.