Electrochemical actuators store electric energy and generate mechanical motion. Here, the authors present an ionic actuator based on a hierarchically porous graphitic carbon nitride electrode, which exhibits high charge storage, fast actuation response, large electromechanical strain and high stability.