Menu

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.

#808080
sRGB 128
Linear 0.216
Gamma 2.4

sRGB transfer curve

sRGB transfer function Reference (linear = sRGB) R G B

sRGB input

Linear RGB sliders (0–1)

0.2159
0.2159
0.2159

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.

Built and maintained by the BestColorPicker team. Last updated .

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

PropertysRGBLinear RGB
Range0–255 bytes or 0–1 floats, gamma-encoded0–1 floats, physical light
Used byCSS, hex, images, Photoshop, FigmaWebGL, Three.js, Unity, Unreal, Blender
Mid value128~0.216 (for the same shade)
Transfer functionPiecewise: linear below 0.04045, then 2.4 powerIdentity — linear light
Correct forDisplay, screenshots, print proofingLighting, shading, blending, tone mapping
Wrong forAdding or multiplying colors, bloom, gradients in 3DDirect 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:

To convert from linear to sRGB:

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 byteLinear (0–1)% of lightNotes
00.00000%Black
320.01441.4%Deep shadow
640.05135.1%Shadow
1280.215821.6%sRGB mid-grey
1880.500050%Linear mid-grey
2551.0000100%White

When you must use linear RGB

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:

FormatExampleUse
GLSL vec3vec3(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#808080Design tools and CSS

Common mistakes

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.

More color tools

Sources and further reading