A system was constructed for measuring magnetic field in 3D space and determining the position and orientation of magnets. Measurements were performed with a Hall-effect Gaussmeter attached to a 3-axis cartesian robot, capable of measuring magnetic fields of ±2 Tesla at spatial increments of as little as 8.75 µm within a working volume of 325mm by 290mm by 100mm. An algorithm was developed for the localization of magnets with known properties based on nonlinear optimization techniques. The Nelder-Mead simplex algorithm and Levenberg-Marquardt nonlinear least-squares algorithm were tested for detection of Neodymium-Iron-Boron magnets. Nelder-Mead performed the best, with a positional error of 2.21mm and orientation error of up to 22.4 degrees.