Abstract This paper presents a data-driven calibration method for tri-axial magnetic sensors that eliminates the need to solve the sensor error model parameters. Calibration was achieved solely through the input and output of the sensor in a known magnetic field. Using both simulation and experimental data, this study employed a Multi-layer Perceptron (MLP) algorithm as the data-driven calibration model. In static and dynamic calibration experiments conducted in a laboratory setting, the calibration performance of MLP was compared with that of traditional calibration algorithms. The experimental results demonstrate that in a static experiment under a 90 μT magnetic field, the sensor error after calibration using the data-driven method was reduced by 30.37% compared to the traditional method. In the dynamic experiments, the proposed method reduced the errors by 71.57% compared with the traditional method. The method proposed in this paper offers a new approach for improving the calibration accuracy and effective measurement range of tri-axial magnetic sensors and holds potential application value for other types of tri-axial sensors.