Electrochemical impedance spectroscopy was used as a novel technique to study gas diffusion through a surface gel. The system under study underwent an alternating current electrograining process that is used in lithography and in capacitor foils. During this process H2 bubbles are trapped inside a gel like structure consisting of 90% water. It is presented that through in situ impedance, the gas diffusion mechanism through the gel can be explained and correlated to the pitting morphology. It is demonstrated that fast gas diffusion leads to a desired uniform aluminum pitting after alternating current processing and that the structure of the gel plays an important role in this process. Copyright © 2016 John Wiley & Sons, Ltd.