Inverse-Designed Narrowband THz Radiator for Ultrarelativistic Electrons THz radiation finds various applications in science and technology. Pump–probe experiments at free-electron lasers typically rely on THz radiation generated by optical rectification of ultrafast laser pulses in electro-optic crystals. A compact and cost-efficient alternative is offered by the Smith–Purcell effect: a charged particle beam passes a periodic structure and generates synchronous radiation. Here, we employ the technique of photonic inverse design to optimize a structure for Smith–Purcell radiation at a single wavelength from ultrarelativistic electrons. The resulting design is highly resonant and emits narrowbandly. Experiments with a 3D-printed model for a wavelength of 900 μm show coherent enhancement. The versatility of inverse design offers a simple adaption of the structure to other electron energies or radiation wavelengths. This approach could advance beam-based THz generation for a wide range of applications.