The CSS filter property can tint a black icon to any color without editing the source asset, but the function chain has no simple inverse. This tool solves for a filter string numerically so you can recolor a black SVG or PNG to an exact target.
How it works
The filter chain is fixed in form and the solver tunes its parameters:
filter: invert(a%) sepia(b%) saturate(c%) hue-rotate(d deg) brightness(e%) contrast(f%);
Each function is modeled as a matrix or clamp operation on the linearized color. Starting from black, the tool runs an SPSA (Simultaneous Perturbation Stochastic Approximation) optimizer: it perturbs all parameters at once, measures the color distance to the target in both RGB and HSL space, and steps the parameters to reduce that distance over many iterations.
Tips and notes
The element must begin as pure black for the generated filter to be accurate, so apply it to a black SVG or prepend brightness(0). Because the optimization is stochastic, two runs can yield slightly different strings with similar loss; re-run if the reported loss is high. A loss under 1 is effectively perfect, and under 5 is fine for small icons where minor color drift is invisible.