Validate hex color

Check CSS hexadecimal colors in three-, four-, six-, or eight-digit notation.

freeworks offlinenothing uploaded
ToolHex Color Validator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The value begins with # and contains exactly 3, 4, 6, or 8 hexadecimal digits. Three and four digits are shorthand channels; four and eight include alpha, while six is the ordinary sRGB form.

  • The accepted lengths are CSS hexadecimal forms.
  • The required # separates colors from bare numbers.

Worked example

Valid 6-Digit Hex
Validate a standard 6-digit hex color code
Input
											#FF5733
										
Output
												Valid hex color (6-digit): #FF5733
											

When to use this

CSS themes, design systems, and SVG or Canvas paint inputs validate colors.

Edge cases

  • #abc expands repeated channel nibbles.
  • #abcd includes alpha and is not opaque #abcd00.
  • #GGHHII fails because only hex digits are permitted.

References