Efficient photocatalysts play a crucial role in producing green and clean hydrogen energy. BiOI is a good material for photocatalytic hydrogen generation. However, the low position of the conduction band also affects its redox ability. We studied the electronic structure and hydrogen evolution reaction (HER) catalytic performance of six nonmetals doped BiOI based on the first principles calculation. The relationship between doping elements and catalytic performance was explained. We used the DFT + U method to find that the band gap values of X-BiOI (X = B, C, N, Si, P, S) are 1.99 eV, 1.23 eV, 1.73 eV, 2.08 eV, 1.40 eV and 1.77 eV, respectively. After nonmetal doping, the bottom position of the conduction band of BiOI rises, which enhances the reduction ability. Specifically, the impurity energy levels generated in the band gap of B and Si doped BiOI reduce the recombination rate of photogenerated carriers, and lower the work function to 5.62 eV and 5.45 eV, respectively. Studies on hydrogen production performance show that B-doped BiOI has the strongest reduction ability and the best catalytic effect, with the lowest ΔGH* (1.57 eV). This research provides some ideas for understanding nonmetal doped materials for the photocatalytic hydrogen evolution system.