Replace a colour in an image — swap one colour for another

Pick the colour to replace and the new colour, set how close a shade must be to count, and the tool swaps it everywhere in the image and tells you how many pixels changed.

Live demo · real result from this tool

Drop images here

or paste with Ctrl+V · nothing is uploaded

Your result appears here — processed on your device.

Processed on your device — nothing is uploaded.

How to use Image Color Replace

  1. Choose one or more images.
  2. Set Colour to replace. The default is white, #ffffff.
  3. Set New colour. The default is green, #22c55e.
  4. Set Tolerance (0–60%), how far a shade may be from the chosen colour and still be fully replaced. The default is 12%.
  5. Set Soft edge (0–30%), a band beyond the tolerance where pixels are only partly changed. The default is 4%.
  6. Press Apply. A note says how many pixels, and what share of the image, were fully replaced.

What it does and when to use it

It is a quick colour swap for flat images: change a white background to a brand colour, recolour a logo or icon, turn a red button blue, or fix a wrong colour in a chart or diagram. It works best where the colour is even, such as graphics, scans and product shots on a plain backdrop.

Find the exact colour first with the image colour picker. To change all colours at once by the same amount, use Image Hue Rotate. To cut out a busy photo background instead of recolouring it, use the background remover.

How it works

The tool measures how far each pixel is from the target colour as a straight-line distance in RGB space:

distance = √((R − R₀)² + (G − G₀)² + (B − B₀)²)

The largest possible distance, from black to white, is √3 × 255 ≈ 441.7. Tolerance and Soft edge are percentages of that.

  • Pixels within the tolerance are fully replaced by the new colour.
  • Pixels in the soft-edge band are blended: the further out, the less they change.
  • All other pixels are untouched, and transparency is kept.

The soft edge stops a hard, jagged outline around shapes that had anti-aliased edges. Everything runs in a background worker on your device; nothing is uploaded.

Worked examples

These values come from the tool’s own function, with the defaults: white to #22c55e, tolerance 12% (distance 53.0) and soft edge 4% (up to distance 70.7).

  • Pure white (255, 255, 255). Distance 0, so it becomes (34, 197, 94), the new green.
  • Off-white paper (240, 240, 240). Distance about 26, inside the tolerance, so it also becomes pure green and is counted as replaced.
  • Light grey (220, 220, 220). Distance about 60.6, inside the soft-edge band, so it is only partly changed, to (114, 207, 148), a pale green.
  • Red to blue, tolerance 20%. With #ff0000 as the colour to replace and #0000ff as the new colour, a pure red pixel becomes pure blue, while an orange-brown (200, 100, 50) is too far away and stays the same.

Limits and tips

  • Shading inside an object is not kept. A replaced area becomes one flat colour, so a shaded red ball turns into a flat blue disc where it was within tolerance.
  • For photos with soft lighting, a hue shift often looks more natural.
  • Keep PNG for graphics so the new edges stay clean.

Frequently asked questions

The colour only changed in some places. What should I do?
Raise the Tolerance a little at a time. Photos and JPEG files contain many near shades of one colour, so a tolerance of 0 catches only exact matches. Watch the pixel count in the result to see the effect.
Other parts of the picture changed too. Why?
The tolerance is too high, so colours that are merely similar are being caught. Lower it. Remember the tool works on the whole image; any area close to the colour changes, not only the one you meant.
Can I make a colour transparent?
No. The new colour is always solid. For a transparent background on a photo, use the background remover.
How do I find the exact colour code to replace?
Use the image colour picker on the same image, copy the HEX code, and paste it into Colour to replace.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close