Two-dimensional dopant profiling is vital for the modelling, design, diagnosis and performance improvement of semiconductor devices and related research and development. Scanning electron microscopy (SEM) has shown great potential for dopant profiling. In this study, the effects of secondary electron (SE) detectors and imaging parameters on the contrast imaging of multilayered p-n and p-i junction GaN specimens via SEM were studied to enable dopant profiling. The doping contrast of the image captured by the in-lens detector was superior to that of the image captured by the side-attached Everhart-Thornley detector at lower acceleration voltages (V acc ) and small working distances (WD). Furthermore, the doping contrast levels of the in-lens detector-obtained image under different combinations of V acc and WD were studied, and the underlying mechanism was explored according to local external fields and the refraction effect. The difference in the angular distributions of SEs emitted from different regions, the response of the three types of SEs to detectors, and the solid angles of detectors toward the specimen surface considerably influenced the results. This systematic study will enable the full exploitation of SEM for accurate dopant profiling, improve the analysis of the doping contrast mechanism, and further improve doping contrast for semiconductors.