Random Grayscale Palette Generator
Generate 2 through 32 sRGB hex colors using zero saturation and bounded lightness and injected randomness.
Description
Generate 2–32 grayscale uppercase sRGB hex swatches from fixed HSL sampling ranges.
Grayscale swatches have equal red, green, and blue byte channels. This generator achieves that relationship by fixing HSL saturation to zero and sampling lightness, rather than converting an image to grayscale.
HSL and hex notation represent sRGB colors.1
The colors array contains #RRGGBB strings without alpha. Swatches are neither sorted nor deduplicated, and count specifies array length rather than the number of distinct colors.
When to use Random Grayscale Palette Generator
Use it for grayscale palette exploration or design fixtures, then judge the swatches in their intended layout.
How to use Random Grayscale Palette Generator and understand its results
- Enter integer count from 2 through 32 and run.
- Inspect colors in returned order and copy their #RRGGBB values into your design application.
- Check actual foreground/background contrast and rerun if another palette is needed. Sort or remove duplicates separately when your application requires that.
| Coordinate | Sampling rule |
|---|---|
| Hue | Fixed at 0 degrees |
| Saturation | Fixed at 0 percent |
| Lightness | 5 inclusive toward 95 exclusive percent |
coordinate = lower + randomDraw × (upper − lower) Three draws are consumed and validated per swatch, even for a coordinate with equal bounds.
The HSL converter wraps hue, computes chroma and its hue-sector RGB contributions, adds the lightness offset, and rounds each channel to an 8-bit uppercase hex value.
{
"input": {
"count": 3
},
"randomDraw": 0.25,
"output": {
"colors": [
"#464646",
"#464646",
"#464646"
]
}
} Count one, noninteger counts, and counts above 32 fail. Invalid consumed random draws also fail rather than being clamped.
Randomly sampled lightness is not an ordered ramp. For a ramp, sort the sampled grays or construct explicit lightness steps separately.
Limitations and assumptions
The default source is Math.random; no seed input or cryptographic entropy guarantee is provided. Repeated runs may select the same result, and the distribution depends on the random source.
There is no contrast guarantee, color-vision check, visual-theme generation, alpha channel, or rendered preview. Rounding can produce duplicate colors even from different coordinate samples.
Alternative or Complementary methods
Use a related palette convention or single-color generator when its output better fits the task. Evaluate chosen foreground/background pairs independently.
References
-
CSS Color Module Level 4 — World Wide Web Consortium
Similar or alternative tools
- Related Color Generator
Generate a related palette or one grayscale level.
- Color Contrast Ratio
Check contrast between selected hex swatches.