Abstract Optical neural networks are considered a promising alternative to mitigate the computational bottlenecks and energy constraints of electronic neural networks; however, their widespread adoption is limited by the absence of efficient optical nonlinear activation units. In this work, we leverage the mature optical component Mach-Zehnder interferometer (MZI) used for constructing optical neural networks and integrate magneto-optical (MO) functional materials into its waveguide arms, achieving a magnetically tunable optical nonlinear activation function. Utilizing finite element simulation software COMSOL Multiphysics, we established a model of the MZI modulator with MO material and optimized the critical structural parameters, such as the radius of the S-bend waveguide, the coupling length of the directional coupler, and the length of the MO waveguide. By adjusting the magnetic field intensity applied to the MO waveguide, the phase difference between the two interfering arms of the MZI can be precisely controlled, thereby enabling the output light intensity to demonstrate the traits of an optical nonlinear activation function. The utilization of MO modulation for achieving optical nonlinear activation function represents a significant advancement over electro-optical and thermo-optical techniques. This method boasts a faster response speed and superior modulation efficiency, coupled with seamless integration and tunability. It holds significant application value in the optical neural networks capable of managing high-speed data processing tasks.