Particle accelerators and storage rings have been transformative instruments of discovery, and, for many applications, innovations in particle-beam cooling have been a principal driver of that success1. Stochastic cooling (SC), one of the most important conceptual and technological advances in this area2–6, cools a beam through granular sampling and correction of its phase-space structure, thus bearing resemblance to a ‘Maxwell’s demon’. The extension of SC from the microwave regime up to optical frequencies and bandwidths has long been pursued, as it could increase the achievable cooling rates by three to four orders of magnitude and provide a powerful tool for future accelerators. First proposed nearly 30 years ago, optical stochastic cooling (OSC) replaces the conventional microwave elements of SC with optical-frequency analogues and is, in principle, compatible with any species of charged-particle beam7,8. Here we describe a demonstration of OSC in a proof-of-principle experiment at the Fermi National Accelerator Laboratory’s Integrable Optics Test Accelerator9,10. The experiment used 100-MeV electrons and a non-amplified configuration of OSC with a radiation wavelength of 950 nm, and achieved strong, simultaneous cooling of the beam in all degrees of freedom. This realization of SC at optical frequencies serves as a foundation for more advanced experiments with high-gain optical amplification, and advances opportunities for future operational OSC systems with potential benefit to a broad user community in the accelerator-based sciences.