How it works: potassium chlorate (KClO3) is a powerful oxidizer, used in matches and fireworks. Sucrose is an easy-to-oxidize energy source. When sulfuric acid is introduced, potassium chlorate decomposes to produce oxygen:
2KClO3(s) + heat —> 2KCl(s) + 3O2(g)
The sugar burns in the presence of oxygen. The flame is purple from the heating of the potassium (similar to a flame test).