We propose a novel miniaturized optical attenuator based on the evanescent-field coupling between two nanofibers. Benefiting from a wavelength-dependent waveguiding property of the coupled structure, a tunable attenuation with maximum extinction ratio of ∼ 20 dB is demonstrated with an ultrawide optical bandwidth up to 0.7 µm in experiment. The wavelength-depended waveguiding properties of both one single nanofiber and coupled nanofibers are investigated in both theory and simulation. Using an adiabatic coupling structure, an attenuation range from -0.16 dB to -18.46 dB is obtained within a spectrum from 1.2 µm-1.7 µm experimentally. Moreover, the simulated results indicate that, the attenuation only shows a slight change of ∼ 0.1 dB with a lateral misalignment of 0.5 µm between the two nanofibers, indicating a high tolerance of this attenuator to the lateral misalignment. Considering the wide bandwidth as well as the ultracompact structure, this attenuator shows high potential in applications such as all-fiber optical sensing and communicating.