The formal charge of an atom in a molecule is the hypothetical charge the atom would have if we could redistribute the electrons in the bonds evenly between the atoms.
Formal charge = (valence electrons of the "free" element) - (unshared electrons) - (bonds)
The sum of the formal charges of all atoms in a molecule must be zero.
The sum of the formal charges in an ion should equal the charge of the ion.