Regular inspection of long-distance oil and gas pipelines plays an important role in ensuring the safe transportation of oil and gas, and inspection on welding defects is an important part of the inspection process. Magnetic flux leakage (MFL) is an electromagnetic non-destructive testing technique which has been commonly utilized to detect welding defects in pipelines. In the present study, Maxwell electromagnetic simulation software was used to carry out numerical study on the welding defects in pipelines, including incomplete penetration and undercut. The Ф406 pipeline with a wall thickness of 7 mm was selected as the study case to establish the numerical model. Setting the life-off value at 1 mm, the distribution of magnetic leakage field was investigated for pipeline without defect, pipeline with incomplete penetration defect and pipeline with undercut defect respectively, the characteristic values describing the depth and width of defects were found. Furthermore, quantified equations which can be used to describe the defect depth were proposed. Finally, experimental research was carried out to validate the effectiveness of the numerical model, and the experimental results showed good consistence with the numerical calculation results. The research results indicate that, it is technically feasible and reliable to diagnose the incomplete penetration and undercut welding defects in pipelines using MFL.