User Rating 0.0
Total Usage 0 times
0 / 10,000
Presets:
Is this tool helpful?

Your feedback helps us improve.

About

Distributing color across text requires mapping each character (or word) to a position on the HSL color wheel. A naive approach assigns random colors, producing visual noise. This tool computes evenly-spaced hue values across a configurable arc of the 360° spectrum, maintaining constant S (saturation) and L (lightness) for perceptual uniformity. The output is real, copy-pasteable code: inline HTML <span> elements, ANSI 256-color escape sequences for terminal use, or raw CSS class mappings. Misconfigured ANSI codes break terminal rendering and corrupt log files. Incorrect HTML color spans produce invalid markup that fails accessibility contrast checks.

The ANSI output maps each computed RGB triplet to the nearest color in the xterm-256 palette using Euclidean distance in RGB space. This approximation loses fidelity below 16 distinct hues. For terminal output, the tool assumes xterm-compatible \x1b[38;5;nm sequences. Results vary on Windows cmd.exe without ANSI support enabled. The HTML output produces valid, accessible markup with each character wrapped in a <span> carrying an inline style attribute.

rainbow text text colorizer ANSI color colored text generator HTML color text terminal colors gradient text

Formulas

Each colorizable unit (character, word, or line) at index i out of n total units receives a hue value computed by linear interpolation across the configured arc:

Hi = Hstart + in 1 × (Hend Hstart)

where Hstart and Hend define the hue arc in degrees (0 - 360), i is the zero-based index, and n is the total count of colorizable units. For a full rainbow, Hstart = 0 and Hend = 360.

The final color is expressed as:

hsl(Hi, S, L)

where S = saturation (0 - 100%) and L = lightness (0 - 100%).

For ANSI 256-color mapping, the nearest palette index is found via Euclidean distance in RGB space:

d = (r1 r2)2 + (g1 g2)2 + (b1 b2)2

where (r1, g1, b1) is the target color and (r2, g2, b2) iterates over the 256 xterm palette entries.

Reference Data

Color ModeHue RangeBest ForOutput FormatColor Count
Classic Rainbow0° - 360°Full spectrum textHTML / ANSI / CSSUnlimited
Warm Gradient0° - 60°Red to yellow themesHTML / CSSUnlimited
Cool Gradient180° - 270°Cyan to purple themesHTML / CSSUnlimited
Pastel Rainbow0° - 360°Soft, readable textHTML / CSSUnlimited
Neon0° - 360°High-contrast displaysHTML / ANSIUnlimited
ANSI 16-ColorFixed paletteLegacy terminalsANSI escape codes16
ANSI 256-ColorMapped from RGBModern terminalsANSI escape codes256
Monochrome GradientSingle hueLightness variation onlyHTML / CSSUnlimited
Custom RangeUser-definedBrand-specific palettesAll formatsUnlimited
Per-WordAnyReadable colored outputAll formatsWord count
Per-LineAnyLog file highlightingAll formatsLine count
Per-CharacterAnyMaximum color densityAll formatsChar count

Frequently Asked Questions

The xterm-256 palette contains only 216 color cube entries (6×6×6 grid in RGB space) plus 24 grayscale shades and 16 system colors. When mapping an arbitrary HSL-derived RGB value, the tool finds the nearest palette entry by Euclidean distance. At high character counts with subtle hue shifts (below approximately 1.5° per step), multiple consecutive characters may map to the same ANSI index, creating visible banding. HTML output preserves full 24-bit color and does not suffer this limitation.
Spaces, tabs, and newlines carry no visible glyph. Assigning color spans to them inflates output size without visual effect and produces invalid ANSI sequences in some terminal emulators. The tool skips whitespace during index assignment but preserves it in the output. This means n (total colorizable units) counts only visible characters, words, or lines depending on selected granularity.
The tool wraps the hue arc correctly. If H_start is 300° and H_end is 60°, the interpolation crosses the 360°/0° boundary, producing a magenta-to-red-to-yellow sequence. The effective arc length is computed modulo 360°. This allows reverse rainbows and partial spectrum selections that cross the red boundary.
The tool splits on whitespace boundaries only. A hyphenated compound like "well-known" counts as one unit and receives one color. Punctuation attached to a word (e.g., 'hello,') stays with that word. For finer control, use per-character mode where each glyph including punctuation gets its own hue step.
Copy the ANSI output and paste it into an echo -e command or printf statement in bash. The escape sequences use the format \x1b[38;5;Nm where N is the palette index. Remember to append \x1b[0m at the end to reset the terminal color. The tool includes this reset automatically. Note: piping ANSI-colored output through programs that strip escape codes (like grep without --color) will display raw escape characters.
Saturation between 70% and 85% with lightness between 40% and 50% maintains sufficient contrast against white (#FFFFFF) for WCAG AA compliance at normal text sizes. The default Pastel preset uses S=80%, L=65%, which sacrifices some contrast for aesthetic softness. For accessibility-critical applications, use the Neon preset (S=100%, L=45%) which exceeds 4.5:1 contrast ratio for all hues except yellow, where lightness drops automatically to 38%.