Launching a SaaS?·Collect waitlist signups before you build — before.run
SandboxPatternsDetectDocsChangelog
Web
#color
#css
#hex
#web

Hex Color

CSS hex color code in #RGB or #RRGGBB format (case-insensitive).

CSS preprocessor toolingDesign token validationColor picker inputs
/
/
Safe
Test String
5 matches
##'#' — literal character
(…)Group #1Capturing group — captures matched text for reuse or extraction
[…]{6}Character class […]Matches any single character listed in this set — repeated exactly 6 times · {6} — exactly 6 times
||| — alternation: matches expression on left OR right
[…]{3}Character class […]Matches any single character listed in this set — repeated exactly 3 times · {3} — exactly 3 times
Pattern: 32 charsInput: 33 chars
100% client-side · private

Valid Examples

  • #fff
  • #FFF
  • #a3B2c1
  • #000000
  • #FF5733

Invalid Examples

  • #gggggg
  • #12345
  • fff
  • rgb(255,0,0)

Usage & Integration

Validate Hex Color natively in your backend or frontend without copying regex strings.

Node / Edge

import { validate } from '@regexto/validators';

validate('hex-color', '...');

Python

from regexto_validators import validate

validate("hex-color", "...")

Go

import "github.com/regex-to/validators-go"

valid, err := validators.Validate("hex-color", "...")

PHP

use RegexTo\Validators\Validator;

Validator::validate('hex-color', '...');

Rust

use regexto_validators::validate;

let is_valid = validate("hex-color", "...").unwrap();