# How exactly does the electrolysis of water work?

When we pass electricity through water it breaks into hydrogen and oxygen gas.

$$\ce{2H2O -> 2H2 + O2}$$

What I couldn't understand is how the electrical energy is converted to breaking the bonds of water molecule. I've searched a lot but couldn't find any satisfactory answers on how the energy conversion happens.

Few thoughts :

1. The fast moving electrons from the battery hit the water molecules breaking them into hydrogen and oxygen ions.
2. I think above idea is incorrect as pure water is an insulator and blocks passage of electrons. Then it might have to do with the electric field that exists through out the water between the anode and cathode. Does this electric field somehow transfer energy to the water molecules and split them ?
3. Above idea makes sense to me as we can think of each $\ce{H2O}$ molecule as a dipole $\ce{2H+-O^2-}$, so it can interact with electric field.
4. I feel all above ideas are silly and there is some sophisticated way to reason this which I don't know yet.

Water dissociates into H+ ions and $\ce{OH–}$ ions; the $\ce{H+}$ ions are attracted to the negative electrode (the cathode) and are converted (reduced) to a hydrogen atom ($\ce{H}$) (i.e. $\ce{e- + H+ -> H}$). This is highly unstable and immediately reacts with another hydrogen atom to produce $\ce{H2}$, molecular hydrogen gas. At the other electrode (the anode), oxidation occurs. The $\ce{OH-}$ ions are attracted to the positive electrode where they are oxidized to form oxygen gas ($\ce{O2}$) and hydrogen ions ($\ce{H+}$). However, if chloride is present, it will oxidize (instead of the $\ce{OH–}$ ions) and form chlorine gas, which will then react with the water to form hypochlorous acid.
The cathode reaction is: $\ce{2H+ + 2e- (cathode) →H2 (g)}$
The anode reaction is: $\ce{2OH– → 4e-(anode) +O2 + 2H+}$
The overall reaction is: $\ce{2H2O → 2H2 (g) + O2 (g)}$