Wavelength to Color Converter (nm → sRGB)
Convert a light wavelength in nanometres (380–780 nm) to an approximate sRGB color, with a clickable rainbow bar and Fraunhofer reference lines.
| 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).
About this tool
ShowHide
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.
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
Random Color Generator
Generate a grid of random colors in HEX, RGB or HSL — pick how many, copy any value with one click, and regenerate instantly for design inspiration.
Random
HSL Color Picker
Drag hue, saturation, lightness, and alpha sliders to dial in a color — copy HEX, RGB, HSL, or a Tailwind arbitrary value.
Color & CSS
Color Format Converter
Convert any color between HEX, RGB, HSL, HSV, OKLCH, and a CSS custom property.
Color & CSS
CMYK ↔ RGB Color Converter (Print Color Space)
Convert between RGB / hex screen colors and CMYK percentages for print — simple, GCR and UCR black generation, plus a total ink coverage readout.
Color & CSS
CSS Named Colors
All 147 CSS / X11 named colors with HEX, RGB, and a live swatch — searchable and grouped by hue.
Color & CSS
Tailwind Color Palette
The full Tailwind CSS v4 default palette — 22 hues × 11 shades, 50 through 950 — with click-to-copy as Tailwind class, HEX, or rgb().
Color & CSS