Lightning is a huge electrical discharge.
Static charges form in a storm composed of ice crystals and liquid water drops. Turbulent winds inside the storm cause particles to rub against one another, causing electrons to be stripped off, making the particles either negatively or positively charged.
The charges get grouped in the cloud, often negatively charged near the bottom of the cloud and positively charged up high. This is an electric field and because air is a good insulator, the electric field becomes incredibly strong. Eventually a lightning bolt happens and the flow of electrons neutralizes the electric field.
This flow of electrons through the lightning bolt creates a very hot plasma, as hot as 50,000 degrees, that emits a spectrum of electromagnetic energy. Some of this radiation is in the form of radio waves and gamma rays.
Instruments that measure these electromagnetic waves allow us to detect lightning bolts that are very far away. Visible light is also part of the spectrum of energy.
At these temperatures, laws of physics state that most of the visible light will be at a wavelength perceived as the color blue, although all wavelengths will be emitted.
The notion of color applies to our perception of what we see, not to the light itself. When we talk about the color of light, we really mean the color we sense with our eyes and then interpret with our mind.
Thus, while the peak energy is at blue wavelengths, the intensity of all the colors tends to saturate our eyes, leading us to perceive the color white – which includes all wavelengths in the visible spectrum.
Over the last 20 years scientists have discovered that lightning also shoots upward out of the top of thunderstorms into the upper atmosphere. These lightning types have distinctive colors, including red sprites and blue jets.