Chlorine bleach contains the active ingredient sodium hypochlorite (NaOCl), while non-chlorine bleaches have different active ingredients for different purposes. Hydrogen peroxide, for instance, is common in color-safe bleaches, and sodium percarbonate or sodium perboate are typically used in "oxygen power" stain removers.
So what, exactly, happens to that ketchup stain on your white t-shirt when you bleach it? In order to understand how chlorine bleach makes a stain "disappear," we need to understand how colors work. Light is both a particle and a wave; its particles, called photons, travel in waves that have a particular length. Not all wavelengths of light are visible to the human eye: infrared light wavelengths are too long for our eyes to see, and ultraviolet wavelengths are too short. The wavelengths we can see are between 400 and 700 nanometers, and they appear as color to us. For example, when light with a wavelength of about 475 nanometers hits the retina in your eye, you perceive the color blue. The light that comes from the ketchup stain on your t-shirt to your retina has a wavelength of about 650 nanometers, which makes it appear red [source: Atmospheric Science Data Center].
The reason the ketchup stain reflects light with a wavelength of 650 nanometers has to do with its chemical makeup. Like most other substances, ketchup is made up of multiple elements joined together by chemical bonds to form molecules. The electrons involved in some of these bonds are capable of absorbing light of certain wavelengths, depending on the characteristics of the chemical bond. The light that the electrons in a substance can't absorb determines the substance's color. So the ketchup stain is absorbing all of the wavelengths of normal light that hit it -- except the 650 nanometer light, which it reflects back to your eye, making it appear red.
Many stains have a network of double bonds between carbon atoms, and this network absorbs light. Chlorine bleach is able to oxidize many of these bonds, breaking them and taking away the substance's ability to absorb light. When this happens, the stain "disappears." When bleach oxidizes the ketchup on your T-shirt, the ketchup stops being able to absorb light. It then appears white, like the rest of the shirt. The remains of the ketchup can still be there; you just won't see the stain anymore. Soaking and washing the shirt can remove the now-invisible stain [source: Barrans].