Electrochemical reaction rates can strongly depend on pH, and there is increasing interest in electrocatalysis in alkaline solution. To date, no method has been devised to address pH in atomic scale simulations. We present a simple method to determine the atomic structure of the metal|solution interface at a given pH and electrode potential. Using Pt(111)|water as an example, we show the effect of pH on the interfacial structure, and discuss its impact on reaction energies and barriers. This method paves the way for ab initio studies of pH effects on the structure and electrocatalytic activity of electrochemical interfaces.