CSS DUOTONE EFFECT GENERATOR

Map an image's dark and light tones to two colors with an SVG filter, then copy the CSS.

In short

Turn any image into a duotone — dark tones mapped to one color, light tones to another — using a pure SVG filter you apply with one line of CSS. Pick a shadow and highlight color, tune contrast and brightness on your own photo or a sample, then copy the CSS and SVG filter. It runs in your browser and your image is never uploaded.

OriginalDuotone result
.duotone {
  filter: url(#duotone);
}

Example output (default settings)

CSS
.duotone {
  filter: url(#duotone);
}
HTML + SVG filter
<svg width="0" height="0" style="position:absolute" aria-hidden="true">
  <filter id="duotone" color-interpolation-filters="sRGB">
    <feColorMatrix type="matrix" values="0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"/>
    <feComponentTransfer>
      <feFuncR type="linear" slope="1.1" intercept="-0.05"/>
      <feFuncG type="linear" slope="1.1" intercept="-0.05"/>
      <feFuncB type="linear" slope="1.1" intercept="-0.05"/>
    </feComponentTransfer>
    <feComponentTransfer>
      <feFuncR type="table" tableValues="0.106 1"/>
      <feFuncG type="table" tableValues="0.078 0.416"/>
      <feFuncB type="table" tableValues="0.392 0.208"/>
    </feComponentTransfer>
  </filter>
</svg>

<img class="duotone" src="photo.jpg" alt="Your image">

How to make a duotone image

  1. 1

    Optionally choose an image from your device to preview, or keep the sample scene.

  2. 2

    Pick a shadow color and a highlight color, or start from a preset pair.

  3. 3

    Adjust contrast and brightness until the result looks right.

  4. 4

    Copy the CSS and the SVG filter, paste the filter once into your page, and add the duotone class to any image.

Questions

How does the CSS duotone effect work?
The image is first converted to grayscale with luminance weights. An SVG feComponentTransfer then maps each gray level onto a straight line between your shadow color and your highlight color, separately for the red, green and blue channels. Black becomes the shadow color, white becomes the highlight color, and everything in between blends.
Why an SVG filter instead of mix-blend-mode?
Blend-mode tricks (grayscale plus a lighten or multiply overlay) only approximate a duotone and break when the shadow color is lighter than the highlight in any channel. The SVG filter maps every channel exactly, needs no extra overlay element, and works on images, backgrounds and videos alike.
Where do I put the SVG filter?
Paste the hidden <svg> block once anywhere in the page body, then reference it with filter: url(#duotone). It must be in the same document as the element using it. If you want several duotones, give each filter its own id and class.
Which browsers support it?
Referencing an inline SVG filter from CSS works in all current versions of Chrome, Edge, Firefox and Safari. The filter id has to live in the same HTML document; external SVG files are not reliable across browsers.
Is my image uploaded anywhere?
No. A picture you choose is shown through a temporary local URL in your browser and never leaves your device. The generated code does not contain your image either.

Related tools

All Color & CSS Tools →

Updated