Linear RGB Converter
Convert between linear RGB and sRGB HEX instantly. Live sliders, gamma curve visualization, and copy-ready float arrays for WebGL, shaders, and physically based rendering.
sRGB transfer curve
sRGB input
Linear RGB sliders (0–1)
Channel ratios
Each ratio is the sRGB transfer function value at that linear input. Values near 0 mean the channel is very dark, where gamma correction matters most.
All conversions
Code snippets
Saved swatches
No saved swatches yet. Save a color to compare how linear and sRGB values relate across your palette.
What is a linear RGB converter?
A linear RGB converter translates between sRGB, the gamma-encoded color space used by screens and CSS, and linear RGB, the physically correct light values used by renderers, shaders, and WebGL. Because sRGB applies a roughly 2.2 power curve, sRGB 128 is not 50% of the light output — it is about 21%. This tool shows both values live, visualizes the transfer curve, and copies float arrays for shaders and engines.
Key takeaways
- sRGB is gamma-encoded and used by CSS, images, and most design tools.
- Linear RGB stores actual light intensity and is what shaders and renderers need.
- sRGB 128 decodes to linear 0.2158, not 0.5.
- Use linear RGB for blending, lighting, shading, bloom, and tone mapping.
- The tool copies GLSL vec3, float arrays, and JSON for your engine.
- Every value is computed with the exact IEC 61966-2-1 sRGB transfer function.
How to use the linear RGB converter
Every field updates live, so you can move from sRGB to linear or from linear to sRGB at any point.
- Enter an sRGB HEX or a linear RGB valueType a HEX code, or enter the linear RGB values directly. Every field and slider updates live, so you can move in whichever direction you need.
- Watch the gamma curveThe live curve shows how your color sits on the sRGB transfer function. Points near the bottom of the curve show where linear light drops fastest.
- Read both color spacesEvery value is shown in sRGB (gamma-encoded, 0-255) and linear RGB (linear light, 0-1) with full precision so you can copy either into your code.
- Check the ratio columnThe tool shows the linear-to-sRGB multiplier for each channel, which is the transfer function value at that input. Designers use it to spot dark values where gamma correction matters most.
- Copy for your engineCopy HEX, sRGB (0-255), linear RGB (0-1), GLSL vec3, CSS rgb(), or linear float arrays for WebGL, Three.js, Unity, and Blender.
- Save and compare swatchesSave colors to a strip and compare how linear and sRGB values change across your palette, then export the strip as JSON.
sRGB vs linear RGB at a glance
The two spaces describe the same color. The difference is the transfer function applied to the numbers.
| Property | sRGB | Linear RGB |
|---|---|---|
| Range | 0–255 bytes or 0–1 floats, gamma-encoded | 0–1 floats, physical light |
| Used by | CSS, hex, images, Photoshop, Figma | WebGL, Three.js, Unity, Unreal, Blender |
| Mid value | 128 | ~0.216 (for the same shade) |
| Transfer function | Piecewise: linear below 0.04045, then 2.4 power | Identity — linear light |
| Correct for | Display, screenshots, print proofing | Lighting, shading, blending, tone mapping |
| Wrong for | Adding or multiplying colors, bloom, gradients in 3D | Direct display without re-encoding |
The sRGB transfer function
sRGB uses a piecewise curve defined in IEC 61966-2-1. To convert from sRGB (0–1) to linear:
- If
c ≤ 0.04045:linear = c / 12.92 - Otherwise:
linear = ((c + 0.055) / 1.055) ^ 2.4
To convert from linear to sRGB:
- If
l ≤ 0.0031308:srgb = l * 12.92 - Otherwise:
srgb = 1.055 * l ^ (1/2.4) − 0.055
The linear segment near black is important. A naive ^ 2.2 approximation gets dark values wrong, which shows up as crushed shadows and a visible step near black in gradients.
Why 0.5 in linear RGB looks like 188 in sRGB
Take linear 0.5. Apply the inverse transfer function:
srgb = 1.055 * 0.5 ^ (1/2.4) − 0.055 ≈ 0.7354
Multiply by 255: 0.7354 * 255 ≈ 188. That is why a linear mid-grey looks like byte 188, not 128. Designers who are used to sRGB are often surprised that a 50% linear value looks so bright — because they are used to 50% sRGB, which is only about 21% of the light.
Common sRGB to linear values
| sRGB byte | Linear (0–1) | % of light | Notes |
|---|---|---|---|
| 0 | 0.0000 | 0% | Black |
| 32 | 0.0144 | 1.4% | Deep shadow |
| 64 | 0.0513 | 5.1% | Shadow |
| 128 | 0.2158 | 21.6% | sRGB mid-grey |
| 188 | 0.5000 | 50% | Linear mid-grey |
| 255 | 1.0000 | 100% | White |
When you must use linear RGB
- Shading and lighting — light adds and multiplies. Doing that in sRGB produces the wrong brightness.
- Blending modes — "add" and "screen" only look correct when the operands are linear.
- Gradients in 3D — interpolating sRGB values makes the middle look muddy.
- Bloom and tone mapping — HDR pipelines assume linear input.
- Physical sky, PBR materials, and IBL — every real renderer expects linear light.
- Image compositing — combining photos with additive light needs linear values.
For DOM rendering and normal CSS, keep using sRGB. The browser re-encodes and displays correctly. Only convert when you cross into a renderer. To build a palette in a perceptual space that is not tied to either curve, use the OKLab Color Converter.
Linear RGB in code
The converter copies values in the formats you actually need:
| Format | Example | Use |
|---|---|---|
| GLSL vec3 | vec3(0.216, 0.216, 0.216) | Fragment and vertex shaders |
| Float array | [0.2159, 0.2159, 0.2159] | Three.js, Unity Color, JSON |
| CSS rgb() | rgb(128, 128, 128) | DOM and stylesheets (sRGB) |
| HEX | #808080 | Design tools and CSS |
Common mistakes
- Using
^ 2.2for everything. It is close but wrong near black. Use the exact piecewise function. - Setting the sRGB byte as a linear float.
128 / 255 = 0.502is not linear 0.5 — it is linear 0.2158. - Displaying linear values as CSS. A linear 0.5 renders as sRGB 128, which is far darker than intended.
- Blending in sRGB. Two sRGB colors averaged channel-by-channel look darker than the expected midpoint, because the sRGB bytes are not proportional to light.
- Ignoring the display transform. Renderers encode linear light to sRGB before display. Skip that step and the whole scene looks wrong.
Frequently asked questions
What is linear RGB?
Linear RGB is sRGB with the gamma transfer function removed. In sRGB, a value of 128 (50% of the byte range) is not 50% of the light output — it is roughly 21%. Linear RGB stores the actual light intensity, where 0.5 means literally half the light. Shading, lighting, blending, and physically based rendering must operate in linear RGB to be correct.
What is the difference between sRGB and linear RGB?
sRGB is the standard gamma-encoded color space used by screens, CSS, images, and most design tools. Linear RGB is the same color with the gamma encoding removed. sRGB matches human perception at low brightness; linear RGB matches the physics of light. GPUs and renderers work in linear RGB, then encode to sRGB for display.
Why does 0.5 in linear RGB look different from 128 in sRGB?
Because sRGB applies a roughly 2.2 power curve. Linear 0.5 of the light becomes sRGB value 188 (about 74% of the byte range), not 128. sRGB 128 decodes to linear 0.2158, which is about 21% of the light. This is why naive RGB blending makes gradients look muddy or too dark.
How do I convert sRGB to linear RGB?
Take the sRGB byte value, divide by 255, and apply the sRGB transfer function: if c <= 0.04045, linear = c / 12.92, otherwise linear = ((c + 0.055) / 1.055) ^ 2.4. This converter applies that formula exactly and shows the result with full precision.
How do I convert linear RGB to sRGB?
Apply the inverse transfer function: if linear <= 0.0031308, sRGB = linear * 12.92, otherwise sRGB = 1.055 * linear ^ (1/2.4) - 0.055. Multiply by 255 and round to get the byte value. The tool applies the exact IEC 61966-2-1 formula.
What is the 2.2 gamma approximation?
A simple approximation is linear = srgb ^ 2.2 and srgb = linear ^ (1/2.2). It is close to the true sRGB curve but not exact, especially near black. Use the real sRGB piecewise function for production code — this converter does.
Where do I need linear RGB?
WebGL, Three.js, Unity, Unreal, Blender, path tracers, physically based renderers, image compositing, bloom, tone mapping, and any shader that adds or multiplies colors. Blending two sRGB colors directly produces the wrong result; blending them in linear RGB produces the expected brightness.
Does CSS use linear RGB?
No. CSS color values such as hex, rgb(), hsl(), and oklch() are interpreted in sRGB, which is gamma-encoded. CSS Color Module Level 4 does not expose linear RGB directly, so if you need linear values for a canvas or WebGL shader, convert them first.
Is sRGB the same as gamma 2.2?
Not exactly. sRGB uses a piecewise curve: a small linear segment near black, then a 2.4 power segment with a 1.055 scale factor. Gamma 2.2 is a common approximation used in older software. The exact sRGB curve is what browsers, GPUs, and this converter use.
What does linear RGB look like?
Linear RGB values look darker than their sRGB counterparts. A mid-grey linear 0.5 appears roughly as bright as sRGB 0.735 (byte 188). This is why shading done in sRGB looks too dark, and shading done in linear RGB looks natural.
Is the linear RGB converter free?
Yes. The tool is free, needs no account, and runs entirely in your browser. Your colors are never uploaded.
Can I copy linear RGB as a float array for a shader?
Yes. The tool exposes a float array view (0 to 1 with several decimal places) and a GLSL vec3 string, ready to paste into a shader, a Three.js material, or a Unity Color constructor.