Fireflies or lightning bugs produce a chemical reaction inside their bodies that allows them to light up. This type of light production is called bioluminescence and is shared by many other organisms, mostly sea critters.
The main purpose of a firefly’s light is to attract mates. The males fly around while turning their lights on and off, hoping to get the attention of a female. Each firefly species flashes light in a unique or special pattern to let the females know who they are and where they are located.