Wavelength to Color Converter (nm → sRGB)
Color
Drag the slider or click anywhere on the rainbow bar to pick a wavelength between 380 nm (violet) and 780 nm (red), and see the matching sRGB approximation as hex / rgb() / hsl(). The bar is rendered as a continuous CSS gradient by sampling 81 wavelengths through Dan Bruton's well-known piecewise polynomial fit to the CIE 1931 color matching functions, with intensity rolloff near the spectrum edges where rods/cones become less sensitive. Underneath is a reference table of Fraunhofer lines — the dark absorption lines Joseph von Fraunhofer catalogued in the solar spectrum in 1814 — including hydrogen-α (Hα, 656.3 nm), the sodium D doublet, the magnesium b line, and the Ca II H and K lines used in spectroscopy and stellar classification.
| A | 759.4 nm | O₂ (telluric) | |
| B | 686.7 nm | O₂ (telluric) | |
| C / Hα | 656.3 nm | Hydrogen | |
| D₁ (Na) | 589.6 nm | Sodium | |
| D₂ (Na) | 589 nm | Sodium | |
| E | 527 nm | Iron | |
| b₁ (Mg) | 518.4 nm | Magnesium | |
| F / Hβ | 486.1 nm | Hydrogen | |
| G / Hγ | 434 nm | Hydrogen / Ca / Fe | |
| H (Ca II) | 396.8 nm | Calcium | |
| K (Ca II) | 393.4 nm | Calcium |
RGB mapping uses Dan Bruton's piecewise approximation to the CIE 1931 color matching functions with intensity rolloff. sRGB has a smaller gamut than the visible spectrum — pure monochromatic colors are out-of-gamut and shown as the closest sRGB match.
How to use
- Drag the slider, or click directly on the spectrum bar to pick a wavelength.
- Read the resulting sRGB color in hex, rgb() and hsl() formats — copy any with one click.
- Click any row in the Fraunhofer line table to jump to that specific wavelength (e.g. hydrogen-α at 656 nm or sodium D at 589 nm).
Frequently asked questions
- Why does the color look dim or washed out near the edges?
- The human eye barely sees wavelengths below ~420 nm or above ~700 nm — the long/short cone responses fall off rapidly. The conversion applies an intensity rolloff in those regions to match that perceptual fade, so a 'pure 380 nm' color is rendered as a dim violet rather than a vivid one.
- Is the RGB mapping accurate?
- It's a useful approximation, not a colorimetric reference. The piecewise function captures the hue progression of the visible spectrum well, but sRGB has a smaller gamut than the visible spectrum — many monochromatic colors (especially deep cyan/teal around 480–500 nm) physically cannot be reproduced on a screen. The shown color is the closest in-gamut approximation.
- What are Fraunhofer lines?
- Dark gaps in the solar spectrum caused by elements in the Sun's atmosphere absorbing specific wavelengths. Joseph von Fraunhofer catalogued ~570 of them in 1814 using a prism, and labelled the strongest ones A–K. They're now the standard reference wavelengths for spectroscopy and stellar classification — the D lines at 589 nm, for example, are the same yellow you see from a sodium street lamp.
- What about ultraviolet and infrared?
- UV (below 380 nm) and IR (above 780 nm) are invisible to humans, so they're shown as black. The wavelength selector is capped to the visible range. For a UV blacklight glow, look at the 400–420 nm range — actual UV is below visibility.
Related tools
Color Blindness Simulator
See how your image looks to people with each of 8 types of color vision deficiency (CVD).
CSS Box Shadow Generator
Visually design CSS box-shadows with multiple layers, live preview, and copy-ready CSS / Tailwind output.
Color Format Converter
Convert any color between HEX, RGB, HSL, HSV, OKLCH, and a CSS custom property.
CSS Gradient Generator
Build linear or radial CSS gradients with multi-stop colors and copy the code.
Color Palette Generator
Build harmonious color palettes from a base color in six schemes.
Color Contrast Checker
Check text/background contrast against WCAG AA and AAA levels.