The effects of the magnetic field on the negative ion (H-) extraction in a negative ion source have been studied by means of a two-dimensional electrostatic particle simulation. A particle-in-cell (PIC) model is used which simulates the motion of the charged particles in their self-consistent electric field. Since most electrons are magnetized by the magnetic field, more H- ions arrive instead of electrons in the region close to the plasma grid in order to ensure the plasma neutrality. In the present article, the effect of the electron diffusion across the magnetic field is also taken into account. Although the effects of the electron diffusion en the difference of the dynamics between electrons and H+ ions, the presence of the magnetic field still has a large contribution to the enhancement of the H- extraction.