Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The <feColorMatrix> SVG filter element changes colors based on a transformation matrix. Every pixel's color value [R,G,B,A] is matrix multiplied by a 5 by 5 color matrix to create new color [R',G',B',A'].
Note: The prime symbol ' is used in mathematics indicate the result of a transformation.
In simplified terms, below is how each color channel in the new pixel is calculated. The last row is ignored because its values are constant.
R' = r1*R + r2*G + r3*B + r4*A + r5 G' = g1*R + g2*G + g3*B + g4*A + g5 B' = b1*R + b2*G + b3*B + b4*A + b5 A' = a1*R + a2*G + a3*B + a4*A + a5Take the amount of red in the new pixel, or R':
It is the sum of:
These specified amounts can be any real number, though the final R' will be clamped between 0 and 1. The same goes for G', B', and A'.
R' = r1 * R + r2 * G + r3 * B + r4 * A + r5 New red = [ r1 * old red ] + [ r2 * old green ] + [ r3 * old Blue ] + [ r4 * old Alpha ] + [ shift of r5 ]If, say, we want to make a completely black image redder, we can make the r5 a positive real number x, boosting the redness on every pixel of the new image by x.
An identity matrix looks like this:
R G B A W R' | 1 0 0 0 0 | G' | 0 1 0 0 0 | B' | 0 0 1 0 0 | A' | 0 0 0 1 0 |In it, every new value is exactly 1 times its old value, with nothing else added. It is recommended to start manipulating the matrix from here.
Like other filter primitives, it handles color components in the linearRGB color space by default. You can use color-interpolation-filters to use sRGB instead.
| Filter primitive element |
| Any number of the following elements, in any order: <animate>, <set> |
This element implements the SVGFEColorMatrixElement interface.
| Filter Effects Module Level 1 # feColorMatrixElement |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Oct 27, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.