Embodiments of the present invention provide a magnetic field sensor. The magnetic field sensor includes at least four XMR elements connected in a full bridge circuit including parallel branches. The at least four XMR elements are GMR or TMR elements (GMR=giant magnetoresistance; TMR=tunnel magnetoresistance). Two diagonal XMR elements of the full bridge circuit include the same shape anisotropy, wherein XMR elements in the same branch of the full bridge circuit include different shape anisotropies.