Two schemes are proposed to compute the nonlinear electro-optic (EO) tensor for the first time. In the first scheme, we compute the linear EO tensor of the structure under a finite electric field, while we compute the refractive index of the structure under a finite electric field in the second scheme. Such schemes are applied to Pb(Zr,Ti)O$_{3}$ and BaTiO$_{3}$ ferroelectric oxides. It is found to reproduce a recently observed feature, namely why Pb(Zr$_{0.52}$Ti$_{0.48}$)O$_{3}$ adopts a mostly linear EO response while BaTiO$_{3}$ exhibits a strongly nonlinear conversion between electric and optical properties. Furthermore, the atomistic insight provided by the proposed ab-initio scheme reveals the origin of such qualitatively different responses, in terms of the field-induced behavior of the frequencies of some phonon modes and of some force constants.