Images of time-of-flight secondary ion mass spectrometry (ToF-SIMS) element distributions at the sample surface may be distorted when dealing with topographically structured samples and an oblique primary ion beam angle. This distortion becomes problematic if topographic feature heights exceed the primary ion beam diameter. Such topographic features may stem from initial topography, but they can also be introduced through differential sputtering of the sample during depth profiling. Current ToF-SIMS software cannot take sample topography or differential sputtering into account. Instead, it assumes a flat surface and the same constant sputter rate for the whole sample which results in laterally and vertically distorted element distributions in depth profiles. Both of these negative effects are demonstrated using a thin layer system. We propose an algorithm to correct both kinds of defects for 2D and 3D ToF-SIMS element distributions by combining them with topographic information. Copyright © 2012 John Wiley & Sons, Ltd.