The nanostructure and local electronic properties of passive films formed on Ni(111) and Fe-18Cr-13Ni(100) have been studied by electrochemical scanning tunneling microscopy (EC-STM) and tunneling spectroscopy combined with imaging (STM/STS). The electronic properties of the granular and inter-granular sites of ultrathin passive films formed on nickel in different conditions (pH, potential) were differentiated by STM/STS for the first time. They reveal local variations in anion or cation vacancies at the grain boundaries of passive films. The measurements on stainless steel reveal local heterogeneity in thickness of the ultrathin native surface oxide layer. The growth of oxide/hydroxide grains is generated by the passivation of the surface and is preferentially localized at the step edges. The in situ study at high-resolution shows crystallized zones after 2-3 hours of passivation. The study by STM/STS of the native oxide film and passive films formed with increasing polarization times shows the presence of two types of sites with different electronic properties assigned to the change in local composition. After passivation the width of the gap increases significantly on both types of sites due to Cr3+ enrichment of the passive film but the local heterogeneity attributed to the concentration of Fe2+ remains. Aging induces similar variations, but these variations are attenuated