Phosphorus-rich carbons (PCs) were prepared by phosphoric acid activation of waste coffee grounds in different impregnation ratios. PCs were characterized by nitrogen and carbon dioxide adsorption and X-ray photoelectron spectroscopy. The results indicate that the activation step not only creates a porous structure, but also introduces various phosphorus and oxygen functional groups to the surface of carbons. As evidenced by cyclic voltammetry, galvanostatic charge/discharge, and wide potential window tests, a supercapacitor constructed from PC-2 (impregnation ratio of 2), with the highest phosphorus content, can operate very stably in 1 M H2SO4 at 1.5 V with only 18 % degradation after 10 000 cycles at a current density of 5 A g−1. Due to the wide electrochemical window, a supercapacitor assembled with PC-2 has a high energy density of 15 Wh kg−1 at a power density of 75 W kg−1. The possibility of widening the potential window above the theoretical potential for the decomposition of water is attributed to reversible electrochemical hydrogen storage in narrow micropores and the positive effect of phosphorus-rich functional groups, particularly the polyphosphates on the carbon surface.