Electronic structure calculations of BiB3O6 crystal from first principles are performed based on a plane-wave pseudopotential method. The linear refractive indices and the static second-harmonic generation ~SHG! coefficients are also calculated by the SHG formula improved by our group. The calculated values are in good agreement with the experimental values. A real-space atom-cutting method is adopted to analyze the respective contributions of the cation and anionic groups to the optical response. The results show that the contribution of the (BiO4)52 anionic group to the SHG coefficients is more pronounced than that of the (BO3)32 and (BO4)52 groups.