Counteracting surface fogging to maintain surface transparency is important for a variety of applications including eyewear, windows and displays. Energy-neutral, passive approaches predominantly rely on engineering the surface wettability, but suffer from non-uniformity, contaminant deposition and lack of robustness, all of which substantially degrade durability and performance. Here, guided by nucleation thermodynamics, we design a transparent, sunlight-activated, photothermal coating to inhibit fogging. The metamaterial coating contains a nanoscopically thin percolating gold layer and is most absorptive in the near-infrared range, where half of the sunlight energy resides, thus maintaining visible transparency. The photoinduced heating effect enables sustained and superior fog prevention (4-fold improvement) and removal (3-fold improvement) compared with uncoated samples, and overall impressive performance, indoors and outdoors, even under cloudy conditions. The extreme thinness (~10 nm) of the coating—which can be produced by standard, readily scalable fabrication processes—enables integration beneath other coatings, rendering it durable even on highly compliant substrates.