Diagram A shows the Lewis structure (LS) of CH_2O. The formal charge on each atom is zero.
To get the formal charge (FC) on the atoms, cut each bond in half, as in Diagram B. Each atom gets the electrons on its side of the cut.
Formal charge = valence electrons in isolated atom - electrons on bonded atom
FC = VE - BE
On O:
VE = 6
BE = 2 lone pairs 2 + 2 bonding electrons = 4 + 2 = 6
FC = 6 – 6 = 0.
On H:
VE = 1
BE = 1 bonding electron
FC = 1 – 1 = 0
On C:
VE = 4
BE = 1 in each single bond + 2 in the double bond = 2 + 2 = 4
FC = 4 - 4 = 0