PurposeThe purpose of this paper is to use the corresponding magnetic sensor and detection method to detect and image the defects of small diameter pipelines. Urban gas pipeline is an energy transportation tool for urban industrial production and social life, which is closely related to urban safety. Preventing the occurrence of urban gas pipeline transportation accidents and carrying out pipeline defect detection are of great significance for the urban economic and social stability. To perform pipeline defect detection, the magnetic flux leakage internal detection method is generally used in the detection of large-diameter long-distance oil and gas pipelines. However, in terms of the internal detection of small-diameter pipelines, due to the heavy weight, large structure of the detection device and small pipe diameter, the detection is more difficult.Design/methodology/approachIn order to solve the above matters, self-made three-dimensional magnetic sensor and three-dimensional magnetic flux leakage imaging direct method are proposed for studying the defect identification. Firstly, for adapting to the diameter range of small-diameter pipelines, and containing the complete information of the defect, a self-made three-dimensional magnetic sensor is made in this paper to improve the accuracy of magnetic flux leakage detection. And on the basis of it, a small diameter pipeline defect detection system is built. Secondly, as detection signal may be affected by background magnetic field interference and the jitter interference, the complete ensemble empirical mode decomposition with adaptive noise method is utilized to screen the detected signal. As a result, the useful signal is reconstructed and the interference signal is removed. Finally, the defect contour inversion imaging of detection is realized based on the direct method of three-dimensional magnetic flux leakage imaging, which includes three-dimensional magnetic flux leakage detection data and data segmentation recognition.FindingsThe three-dimensional magnetic flux leakage imaging experimental results shown that, compared to the actual defects, the typical defects, irregular defects and crack groove defects can be analyzed by the magnetic flux leakage defect contour imaging method in qualitative and quantitative way respectively, which provides a new idea for the research of defect recognition.Originality/valueA three-dimensional magnetic sensor is made to adapt the diameter range of small diameter pipeline, and based on it, a small-diameter pipeline defect detection system is built to collect and display the magnetic flux leakage signal.