Principles of nuclear fusion
The magic of nuclear fusion is synthesis of usually two lightweight atom nuclei and creation of one heavier. If synthesized nuclei are lighter than nickel, reaction produces energy; on the contrary synthesis of two heavier nuclei absorbs energy. That is because we use fission to gain energy from heavy elements like uranium or plutonium. I will further describe especially fusion of lightweight elements applicable in energetics.
How nuclear fusion works
Imagine, you want to fuse two deuterons that may form tritium nuclei and one proton or 3He and one neutron with the same probability. Released energy must be the same, so I chose latter case, which you can see at fig. 1.
D + D → 3He + Neutron
Weight of deuterons on left side is 2x2.014 atomic mass units (amu), weight of single neutron is 1.00866 amu and 3He weights 3.015 amu. Total mass on left side is 4.037 amu and on right side 4.0237 amu.
Is it possible? Why not? Einstein found that matter is only form of energy, thus law of conservation of matter is form of law of conservation of energy. Because law of conservation of energy always tells the truth (as we know today), we can figure out amount of energy released during fusion from difference in mass on left and right side.
I am sure you know famous Einstein's formula.
Therefore energy gained from fusion reaction of two deuteron nuclei is 6.627x10-15 J. One mol (equals 2 grams) of deuterons would release 1.995 GJ of energy. It is quite enough, don't you think?
There is more possible nuclear fusion of deuterium, tritium, lithium etc. The principle is analogous. Because this description is very simplified, it has almost no sense to describe other fusion reactions. For more information check references especially important fusion reactions.