Magnetars are the neutron stars with the highest magnetic fields up to 1015–1016 G. It has been proposed that they are also responsible for a variety of extra‐galactic phenomena, ranging from giant flares in nearby galaxies to fast radio bursts. Utilizing a relativistic mean field model and a variable magnetic field configuration, we investigate the effects of strong magnetic fields on the equation of state and anisotropy of pressure of magnetars. It is found that the mass and radius of low‐mass magnetars are weakly enhanced under the action of the strong magnetic field, and the anisotropy of pressure can be ignored. Unlike other previous investigations, the magnetic field is unable to violate the mass limit of the neutron stars.