Xerobit

Invert Color: Get the Negative of Any Hex or RGB Value

Enter a hex code like #336699 or an RGB value like rgb(51, 102, 153) to get the inverted color instantly. The tool shows both hex and RGB output plus whether black or white text has better contrast on each color. It runs in your browser with no data sent to a server. Use this invert color utility to create negative versions of your palette for dark mode previews, hover states, or accessibility testing.

Result

  • Original hex
    #336699
  • Original rgb
    rgb(51, 102, 153)
  • Inverted hex
    #cc9966
  • Inverted rgb
    rgb(204, 153, 102)
  • Best text on original
    white

    Contrast: 6.00:1

  • Best text on inverted
    black

    Contrast: 8.32:1

How to use the color inverter

  1. Enter a color in the input box using hex (#rrggbb or #rgb) or RGB format (rgb(r,g,b) or rgba(r,g,b,a)).
  2. See the inverted color appear instantly below in both hex and RGB notation.
  3. Check contrast to decide whether black or white text is more readable on the original and inverted colors.
  4. Copy the values you need for CSS, design tools, or code.

How color inversion works

Color inversion subtracts each channel from 255. For an RGB color (r, g, b) the negative is (255-r, 255-g, 255-b). In hex each pair of digits represents one channel from 00 to ff (0 to 255). The same arithmetic applies: ff - channel.

Example: #336699 has channels 0x33 (51), 0x66 (102), 0x99 (153). Inverted channels are 204 (0xcc), 153 (0x99), 102 (0x66) giving #cc9966. This invert color operation is symmetric: applying it twice returns the original color.

The tool also expands three-digit hex codes (for example #f0c becomes #ff00cc) before inversion, so you can use shorthand notation without extra steps.

Common color inversions

The table below shows frequent colors and their negatives. Use it as a quick reference when designing inverted UI states.

OriginalHexInvertedHex
Black#000000White#ffffff
White#ffffffBlack#000000
Red#ff0000Cyan#00ffff
Lime#00ff00Magenta#ff00ff
Blue#0000ffYellow#ffff00
Muted blue#336699Pale orange#cc9966
Gray#808080Inverted gray#7f7f7f

When to use inverted colors

Inverted colors are useful for several design scenarios:

  • High contrast modes: accessibility settings that flip the entire palette for users who need inverted contrast.
  • Hover and active states: buttons or links that invert on interaction to provide clear visual feedback.
  • Negative space designs: logos or icons that work in both positive and negative form, useful for versatile branding.
  • Dark mode prototypes: quickly preview how a light palette looks when inverted without rewriting all color values.
  • Data visualization: alternating series colors by inverting a base hue to maintain harmonic relationships.

Each case benefits from an instant invert color calculation to keep the workflow fast and accurate.

Contrast and readability

The tool calculates the relative luminance of each color using the sRGB formula and compares the contrast ratio against black (#000000) and white (#ffffff). The higher ratio wins. WCAG AA requires 4.5:1 for normal text and 3:1 for large text; AAA requires 7:1 and 4.5:1 respectively.

Inversion does not keep contrast constant, because sRGB luminance is not linear in the channel values: the luminance of the inverted color is not simply one minus the original. Always read the ratios the tool reports for each color instead of assuming the inverted color works with the same text color. The result rows show the recommended text color and the exact contrast ratio for both the original and the inverted color.

CSS filter invert()

You can invert an entire element in CSS without changing its color values:

.inverted { filter: invert(100%); }

This inverts all colors including images and background colors. For a single color value, use the hex or RGB output from this tool directly in your stylesheet. The CSS filter approach is handy for whole-page dark mode toggles, while the calculated values are better for precise component theming.

Programmatic inversion in JavaScript

If you need to invert colors in your own scripts, the logic is straightforward:

function invertHex(hex) {
const clean = hex.replace('#', '');
const expanded = clean.length === 3 ? clean.split('').map(c => c + c).join('') : clean;
const num = parseInt(expanded, 16);
const inverted = 0xFFFFFF ^ num;
return '#' + inverted.toString(16).padStart(6, '0');
}

This snippet handles both three and six digit hex, performs a bitwise XOR with 0xFFFFFF (equivalent to 255 per channel), and returns a lowercase six-digit hex string. You can adapt it for RGB arrays or other formats as needed.

Worked examples

ExampleInputResult
Blue to orangeColor: #336699Original hex: #336699; Original rgb: rgb(51, 102, 153); Inverted hex: #cc9966; Inverted rgb: rgb(204, 153, 102); Best text on original: white; Best text on inverted: black
Black to whiteColor: #000000Original hex: #000000; Original rgb: rgb(0, 0, 0); Inverted hex: #ffffff; Inverted rgb: rgb(255, 255, 255); Best text on original: white; Best text on inverted: black
White to blackColor: #ffffffOriginal hex: #ffffff; Original rgb: rgb(255, 255, 255); Inverted hex: #000000; Inverted rgb: rgb(0, 0, 0); Best text on original: black; Best text on inverted: white
Red shorthandColor: #f00Original hex: #ff0000; Original rgb: rgb(255, 0, 0); Inverted hex: #00ffff; Inverted rgb: rgb(0, 255, 255); Best text on original: black; Best text on inverted: black
RGB notationColor: rgb(255, 128, 0)Original hex: #ff8000; Original rgb: rgb(255, 128, 0); Inverted hex: #007fff; Inverted rgb: rgb(0, 127, 255); Best text on original: black; Best text on inverted: black

FAQ

What does invert color mean?

Inverting a color replaces each red, green, and blue channel with its opposite on the 0-255 scale. The result is the photographic negative of the original color.

How do I invert a color in CSS?

Use filter: invert(100%) on an element to invert everything inside it. For a single color value, compute the inverted hex or RGB and use that value directly.

Does inversion preserve brightness?

Not exactly. A light color generally becomes dark and a dark color becomes light, but perceived brightness is not mirrored perfectly because the eye weights red, green and blue differently. Mid-grays such as #808080 invert to almost the same brightness.

Can I invert RGB values directly?

Yes. Subtract each channel from 255: r2 = 255 - r1, g2 = 255 - g1, b2 = 255 - b1. This tool does that calculation for you.

What is the inverse of white?

White (#ffffff, rgb(255,255,255)) inverts to black (#000000, rgb(0,0,0)).

How does this tool handle 3-digit hex?

It expands each digit to two digits (e.g., #f0c becomes #ff00cc) before inverting, then returns a 6-digit hex result.

Is the inverted color always accessible for text?

Not automatically. The tool shows which of black or white text has a higher contrast ratio on each color. Check the ratios against WCAG guidelines for your text size.