The solid potassium chlorate is melted into a liquid.
KClO + energy → KClO 
The liquid potassium chlorate decomposes into potassium perchlorate and potassium chloride.
4 KClO → KCl + 3 KClO
The potassium perchlorate decomposes into potassium chloride and oxygen.
KClO → KCl + 2 O
The sugar in the candy reacts with oxygen, forming water and carbon dioxide. The reaction is exothermic and produces heat, smoke, and fire.
CHO + 12 O → 12 CO + 11 HO  + energy