A theoretical framework has been established to investigate the modulational instability of electromagnetic waves in magnetized electron–positron plasmas. The framework is capable of analyzing electromagnetic waves of any intensity and plasmas at any temperature. A fully relativistic hydrodynamic model, incorporating relativistic velocities and thermal effects, is used to describe the relativistic dynamics of particles in plasmas. Under the weakly magnetized approximation, a modified nonlinear Schrödinger equation, governing the dynamics of the envelope of electromagnetic waves in plasmas, is obtained. The growth rate of the modulational instability is then given both theoretically and numerically. By analyzing the dependence of the growth rate on some key physical parameters, the coupled interplay of relativistic effects, ponderomotive forces, thermal effects and magnetic fields on electromagnetic waves can be clarified. The findings demonstrate that specific combinations of physical parameters can significantly enhance modulational instability, providing a theoretical basis for controlling the propagation of electromagnetic waves in plasmas. This framework has broad applicability to most current laser–plasma experiments and high-energy radiation phenomena from stellar surfaces.