In this study, two different characterization techniques based on Kelvin probe force microscopy (KPFM) have been used to investigate the dielectric and substrate charging in electrostatic micro- and nano-electromechanical systems (MEMS and NEMS). The first technique (KPFM-MEMS) has been employed to study the discharging process on a microscopic scale in a charged MEMS dielectric film. This has been performed by monitoring the surface potential decay with time of charged PECVD silicon nitride films implemented in electrostatic capacitive MEMS switches. The second methodology, KPFM-thin films (KPFM-TF), has been applied to investigate the charging/discharging processes in bare SiNx films as well as the substrate charging phenomenon. It makes use of the atomic force microscope tip to simulate charge injection through a single asperity, and then measure the induced surface potential. The influence of the SiNx film thickness and deposition conditions has been studied. Moreover, the impact of bias amplitude and bias polarity applied during charge injection has been explored. Fourier transform infrared spectroscopy and x-ray photoelectron spectroscopy material characterization techniques have been used to determine the chemical bonds and compositions, respectively, of the SiNx films being investigated. The nanoscale KPFM results obtained in this study reveal an accurate understanding of both the dielectric charging and the substrate charging that take place in electrostatic MEMS/NEMS devices.