A device for analyzing substances in a sample on the basis of a measurement of nuclear magnetic resonances including a magnetic field device configured to generate a magnetic field. The device is configured such that, in order to detect magnetic resonances induced in the sample by the generation of the magnetic field, provision is made of at least one magnetic field sensor which comprises at least one sensitive component with diamond structures. The diamond structures have nitrogen vacancy centers.