A diffraction grating is an optical tool that features many parallel slits or grooves etched onto a flat surface.
When light passes through the grating, it diffracts or spreads out into a spectrum of colors. Unlike refraction, such as when white light spreads out when passing through a prism, diffraction is caused by wave interference effects.
The direction and intensity of the diffracted light depend on the spacing between the slits and the wavelength of the incident light. Diffraction grating slits are typically microscopic, as the optimal effects occur when the slits are around the same size as the wavelength of light passing through. Gratings typically range from a few hundred to several thousand slits per millimeter.