The answer is that fireflies contain an organic compound in their abdomens called luciferin. As air rushes into the abdomen, it reacts with the luciferin. A chemical reaction gives off the familiar glow of a firefly. This light is sometimes called “cold light” because it generates so little heat. The firefly can regulate the airflow into the abdomen to create a pulsating pattern.

Some experts think the firefly’s flashy style may warn predators of the insect’s bitter taste. On the other hand, some frogs don’t seem to mind. They eat so many fireflies that they themselves begin to glow. Male fireflies also light up to signal their desire for mates – and willing females attract the males with flashes of their own.

More Info: earthsky.org