Skip to main content
Back to Numbers generators

Numbers

Random Hex Color Code Generator

Used by developers, writers, and creators worldwide.

A random hex color code generator saves you from manually inventing color values when you need a quick batch for prototyping, testing, or creative exploration. Each code is a six-character hexadecimal string encoding red, green, and blue channels — 256 levels each — giving a total palette of over 16 million possible colors. Randomization surfaces combinations you'd never reach by hand, which is exactly the point. This generator lets you set how many codes you need in one pass (default is 8), toggle the standard # prefix that CSS and design tools expect, and choose uppercase or lowercase output. Uppercase like #3A7FCC suits most style guides and design token formats; lowercase like #3a7fcc fits handwritten CSS and Sass conventions.

Loading usage…

Free forever — no account required

How to use

  1. Choose your options above
  2. Click Generate
  3. Copy your result

Detailed instructions

  1. Set the 'How Many Codes' field to the number of hex values you need in one batch.
  2. Choose whether to include the # prefix based on where you will paste the codes — CSS needs it, some tools do not.
  3. Select uppercase or lowercase to match your project's code style or design token conventions.
  4. Click the generate button to instantly produce the full list of random hex color codes.
  5. Copy individual codes or the entire list and paste directly into your CSS, design file, or script.

Use Cases

  • Seeding a generative art canvas in p5.js with a fresh batch of unpredictable fill colors
  • Populating CSS custom properties or Sass variables during early-stage design system exploration
  • Stress-testing a hex color validation function in Jest with varied, non-curated input values
  • Assigning distinct category colors to a Chart.js or D3 dataset without manually picking each one
  • Filling temporary Figma frame swatches before a real brand palette is finalized

Tips

  • Generate 20 or more at once and scan visually — your eye will catch interesting outliers faster than iterating one by one.
  • If results look muddy, add HSL-based filtering in your code: keep only codes where saturation exceeds 50% after conversion.
  • Pair random hex codes with a contrast checker immediately — many random combinations fail WCAG AA contrast ratios for text.
  • Use lowercase output when writing Sass or CSS custom properties, since most autoformatters normalize to lowercase anyway.
  • For data visualization, generate twice as many codes as you need and discard any that look too similar in lightness to neighboring values.
  • Copy the raw codes without the # prefix when pasting into Android XML layouts or Swift UIColor hex initializers that handle the prefix internally.

FAQ

can I paste these hex codes directly into CSS or Tailwind config

Yes — any code with the # prefix drops straight into a CSS color property, like background: #4E9AF1, and browsers render it immediately. For Tailwind, paste the value (with or without #, depending on your config format) into your theme's color object in tailwind.config.js.

why do so many random hex colors look muddy or unsaturated

The full 16.7 million color space contains far more mid-range, muted tones than vivid or pastel hues, so uniform randomness skews toward dull results. Use the generated codes as starting points and nudge them in a color picker toward higher saturation or lightness if you need bolder output.

when should I turn off the # prefix

Some tools expect the raw six-character code without the hash — Android XML color resources, certain JSON config files, and spreadsheet conditional formatting inputs are common cases. Toggle 'Include # Prefix' to off and the output is ready to paste without manual editing.