A magnetic field sensor comprises a first and a second carrier foil and a spacer arranged there between. The spacer delimits a sensing region of the sensor in which the first and second carrier foils can be brought together against the their resiliency. At least two electrodes are arranged in the sensing region in such a way that an electrical contact is provided between them when the first and second carrier foils are brought together. The magnetic field sensor further comprises additional magnetizable layer associated with the first or the second carrier foil so that the first and second carrier foils can be brought together in response to a magnetic field.