A form of potential energy is set up between electric charges analagous to the case when two masses are separated. The easiest way to understand electrical energy is to consider a capacitor.

In a capacitor a potential difference is set up (by a battery) between two conducting plates. This voltage difference V encourages charges to move from one plate to the other. Since like charges repel, work needs to be done to force more of them onto the same plate. The work required dW to move an increment dq of charge is given by¹

dW = dqV
In a capacitor, the total amount of charge that may be moved in this way is proportional to the potential difference V. The constant of proportionality in this case is known as the capacitance C.
q = CV
Substituting this expression for q into the first expression and integrating over q from zero to Q,
W = ∫ (q/C) dq
one obtains
W = Q²/2C = (C/2)V²
The electic field E is given by the gradient of the potential difference. Since this changes linearly over a distance d from one conductor to the other we have E=Vd. Furthermore the capacitance may be written
C = ε A/d
where A is the area of the conducting plates. Thus, the work done is given by,
W= (ε A/2d)(Ed)²