Nanofiber filters work by leveraging the high surface area-to-volume ratio and the small pore sizes of nanofibers. When air or liquid passes through the filter, particles and contaminants are trapped on the surface of the nanofibers due to mechanisms such as interception, inertial impaction, and Brownian motion. These mechanisms are effective in capturing a wide range of particle sizes, including bacteria, viruses, and fine dust.