Home › Developer Tools › CSS Color Filter Generator

CSS Color Filter Generator

Enter a target HEX color and get a CSS filter chain that turns a black icon, SVG or PNG into that color. Each result shows the color it really produces and an accuracy score, so you know how close the match is.

Last updated:

3- or 6-digit HEX code, e.g. #E91E63

Keeps it working on icons that are not pure black

Change to get a different (equally valid) filter chain

Enter your values to see the result.
Advertisement
Advertisement

How to use the CSS Color Filter Generator

  1. Enter your target color as a HEX code.
  2. Keep the prefix on unless your icon is guaranteed pure black.
  3. Click Generate and check the accuracy score and the icon preview.
  4. Try a higher effort or another variation if the score is below 95%.
  5. Copy the CSS and apply it to your img, SVG or icon element.

How the CSS filter chain works

Starting from black (0, 0, 0), each function changes the color in a predictable way:

FunctionWhat it does to the colorRange used
invert(x%)Moves black toward white: each channel becomes x (as a fraction)0-100%
sepia(x%)Blends toward a warm brown tone, giving the gray some color0-100%
saturate(x%)Multiplies color intensity; large values push toward a vivid hue0-7500%
hue-rotate(xdeg)Rotates the hue around the color wheel0-359deg
brightness(x%)Scales all channels up or down0-200%
contrast(x%)Pushes channels away from or toward middle gray0-200%

The search uses SPSA (simultaneous perturbation stochastic approximation), a gradient-free optimizer that nudges all six values at once, then polishes the rounded whole numbers so the chain you copy is the one that was scored.

Reading the accuracy score

ΔE2000AccuracyWhat you see
0-198-100%No visible difference
1-296-98%Visible only side by side, to a trained eye
2-590-96%Close; fine for most icons
5-1080-90%Noticeably different: try Thorough mode
10+below 80%Poor: use another variation

Tips

  • Filters render in the browser per pixel; anti-aliased edges are colored too, so icons stay smooth.
  • For hover states, put a second filter on :hover and add transition: filter .2s.
  • Very light pastels and near-whites are the hardest to hit exactly; Thorough mode usually helps.

Frequently asked questions

How do I change the color of an SVG with a CSS filter?

Apply a filter chain to the element, for example filter: brightness(0) saturate(100%) invert(31%) sepia(...) ... The first two functions make the icon black, and the remaining ones shift black to your target color. This works for SVGs loaded with img tags and for PNG icons, where fill and color cannot be changed.

Why do I need brightness(0) saturate(100%) first?

The chain is calculated starting from pure black. brightness(0) turns any color into black, so adding it first makes the same filter work on gray, colored or white icons. If your icon is already #000000 you can drop it.

Why isn't the color 100% exact?

CSS filters are a chain of fixed math operations and can't reach every color precisely, and the values are rounded to whole numbers. The tool searches for the closest combination and reports the color difference: below ΔE 1 the difference is invisible, below 2 it is barely perceptible.

How is the accuracy score calculated?

The tool simulates the filter chain using the matrices from the W3C Filter Effects specification, converts the result and the target to CIELAB and measures the CIEDE2000 color difference. Accuracy = 100 − 2 × ΔE, capped between 0 and 100%.

Should I use a filter or change the SVG fill?

If you control the SVG markup, setting fill or using fill: currentColor is simpler, exact and cheaper to render. Filters are best when the icon is an img, a background image or a PNG you can't edit.

Does the filter work on colored or transparent parts?

Transparent areas stay transparent, because filters only change color, not alpha. With the prefix every visible pixel becomes the target color, so multi-color icons turn into a single color.

Why do I get a different chain each time I change the variation?

Many different chains produce almost the same color. The search starts from random points, so another variation number can return a different but equally valid filter.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

CSS Filter GeneratorAdjust blur, brightness, contrast, hue, sepia and drop-shadow on an image and copy the CSS filter.HEX to RGBConvert HEX colors to RGB and other formats.Hex Opacity CalculatorConvert opacity percent to a 2-digit HEX alpha code and full #RRGGBBAA color, with a 0-100% table.Color Code ConverterConvert a color between HEX, RGB, HSL, HSV, CMYK, LAB, LCH and OKLCH with a live swatch.Open Graph PreviewPaste OG tags and preview how links look on Facebook, X and LinkedIn.YouTube Embed Code GeneratorCreate responsive YouTube embed code with start time, autoplay, loop and privacy mode.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.CSS Flexbox GeneratorBuild flexbox layouts visually: set container and item properties, then copy the CSS and HTML.Twitter Card GeneratorCreate X / Twitter Card meta tags with Open Graph fallbacks, character counters and a live preview.CSS Grid GeneratorDraw CSS grid layouts: set tracks and gaps, drag to name areas, then copy the CSS and HTML.PX to REM ConverterConvert px to rem or em and back, with a 1-100px table and a whole-CSS converter.Glassmorphism CSS GeneratorDesign frosted-glass UI cards with blur, transparency and border sliders, then copy the CSS.CSS Text Shadow GeneratorLayer CSS text shadows with a live preview and neon, 3D, outline and retro presets.HTML Editor (Live Preview)Write HTML, CSS and JavaScript and see a live, sandboxed preview as you type.HTML to JSX ConverterConvert HTML to valid React JSX: className, htmlFor, style objects, self-closing tags and events.CSS Clip-Path GeneratorDraw CSS clip-path shapes by dragging points: polygons, circle, ellipse and inset. Copy the CSS.CSS Animation GeneratorCreate CSS keyframe animations from 23 presets with live preview, timing controls and Copy CSS.CSS Triangle GeneratorMake CSS triangles in 8 directions with the border trick or clip-path. Set size and color, copy CSS.CSS Loader GeneratorPick from 14 pure CSS spinners and loaders, set color, size and speed, then copy the HTML and CSS.Cubic Bezier GeneratorDrag the control points to design a CSS easing curve, compare it with linear and copy cubic-bezier().CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.Google Maps Embed GeneratorTurn an address or coordinates into responsive Google Maps iframe embed code, no API key.Neumorphism CSS GeneratorDesign soft UI neumorphic shapes with live preview and copy the box-shadow CSS.SVG Wave GeneratorMake layered SVG waves for section dividers and export SVG, PNG or a CSS background.SVG Blob GeneratorGenerate random organic SVG blob shapes with gradients and export SVG, PNG or CSS clip-path.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.CSS @font-face GeneratorTurn font files or URLs into ready-to-paste @font-face rules with weights, styles and a preview.CSS Media Query GeneratorBuild @media rules for widths, orientation, dark mode and hover, or get framework breakpoints.CSS Scrollbar GeneratorStyle scrollbars: width, colors, radius and hover, with ::-webkit-scrollbar and scrollbar-color CSS.CSS Sprite GeneratorPack many icons into one sprite sheet PNG and get CSS classes with background-position.CSS Text Gradient GeneratorMake gradient text with background-clip:text: color stops, angle, font preview and fallback CSS.CSS Toggle Switch GeneratorDesign pure-CSS toggle switches: size, colors, shape and animation. Copy accessible HTML + CSS.CSS Tooltip GeneratorBuild pure CSS tooltips: position, arrow, colors, padding and animation. Copy HTML and CSS.HTML Form BuilderDrag and drop form fields with labels and validation, then copy accessible HTML and CSS code.Iframe GeneratorCreate iframe embed code: size or responsive ratio, border, allow, sandbox, lazy load, live preview.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.CSS Transform GeneratorRotate, scale, skew and translate an element with sliders and copy the CSS transform code.Font Pairing ToolPreview Google Font heading and body pairs on real layouts and copy the embed code and CSS.HTML Accessibility CheckerPaste HTML to find WCAG accessibility problems with impact level, the failing element and a fix.HTML Image Map GeneratorDraw clickable rectangle, circle and polygon hotspots on an image and get image map HTML.SVG ViewerOpen or paste SVG code to preview it live with zoom, backgrounds, size info and PNG export.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.SVG Path EditorEdit an SVG path d attribute visually: drag points, edit commands, convert, scale and minify.SVG to CSS Data URITurn SVG code into a small URL-encoded data URI for CSS backgrounds, with Base64 size comparison.SVG to JSXTurn SVG code into a clean React component: camelCase attributes, style objects, TypeScript.Tailwind CSS Cheat SheetSearchable Tailwind class to CSS reference with live previews, class decoder and color palette.Web App Manifest GeneratorCreate a PWA manifest.json and every app icon size from one image, downloaded as a ZIP.CSS Background Pattern GeneratorMake pure-CSS stripes, dots, checkerboard, zigzag and grid backgrounds and copy the code.CSS Gradient Animation GeneratorCreate animated gradient backgrounds: pick colors, angle and speed, preview live and copy the CSS.CSS Hover Effects GeneratorPick button, link and image hover effects, tweak colors and timing, and copy the HTML and CSS.CSS InlinerMove CSS from style blocks into inline style attributes so HTML emails render in every client.CSS Shape Divider GeneratorCreate wave, tilt, curve and triangle section dividers and copy the SVG, HTML and CSS.
See all 52 Web, HTML & CSS Tools →