Colors
Hex Color Formats Generator
Used by developers, writers, and creators worldwide.
A hex color formats generator saves you the context-switching that slows down UI work. Paste a HEX code into Figma, then need rgb() for a React component, hsl() for a Sass mixin, and a CSS custom property for your design tokens? This tool generates all four representations simultaneously for every color — no converters, no manual math. Set the count to however many colors your palette needs, hit generate, and lift exactly the format each tool is asking for. The HSL output is especially handy for deriving hover or disabled states by adjusting lightness. The CSS variable line is already formatted as a declaration, ready to drop into any :root block.
Loading usage…
Free forever — no account required
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Set the Number of Colors input to how many colors your project needs — 1 for a single token, more for a palette.
- Click Generate to produce that many colors, each displayed with all four format representations.
- Scan the output and identify the format your current tool needs — HEX, RGB, HSL, or CSS variable.
- Select and copy the specific line or lines you need, then paste directly into your stylesheet, config file, or component.
Use Cases
- •Grabbing rgb() values to pass into a WebGL shader or HTML canvas API
- •Populating a :root block with CSS custom property tokens for a shadcn/ui or Radix UI theme
- •Seeding a Storybook component style guide with placeholder brand colors before final assets arrive
- •Prototyping a 5-color UI palette in under a minute without opening Figma
- •Teaching HEX, RGB, and HSL relationships side-by-side in a frontend workshop
Tips
- →If a generated color is too dark or too light, check the HSL lightness value — regenerate until it lands between 35% and 65% for most UI use cases.
- →Generate 6–8 colors at once, then cherry-pick the ones with complementary hue values (roughly 30–60 degrees apart on the HSL scale) for a natural palette.
- →The CSS variable output names colors sequentially as --color-1, --color-2, etc. — rename them semantically (--color-primary, --color-accent) before adding to a real project.
- →For button hover states, take the generated HSL value and manually reduce lightness by 8–12% to get a darker variant without needing a separate generated color.
- →When working in Figma alongside code, keep the HEX values as your source of truth — paste them into Figma's color picker to ensure exact visual parity with your CSS.
FAQ
when should I use HSL instead of HEX in CSS
Use HSL when you need to derive related shades programmatically — for example, dropping lightness by 10% to darken a button on hover. HEX is more compact for static, unchanging values. If you're building a design token system, HSL gives you the most flexibility for generating tonal scales.
how do I use a CSS custom property color in my stylesheet
Declare it inside a :root selector like --color-brand: #ff6b35, then reference it anywhere with var(--color-brand). Change the value once and it updates everywhere it's used. This generator outputs the declaration line already formatted, so you can paste it directly into your :root block.
are randomly generated colors safe to use in production UI
Random colors can land anywhere in the spectrum — very dark, very light, or low-contrast — so always check accessibility before shipping. Use the HSL lightness value as a quick filter: aim for 30–70% for most UI surfaces. Regenerate until you get values that meet your contrast requirements, then lock them into your design tokens.