Colorful Rainbow Text Generator
Create colorful rainbow text online with this free HTML and CSS generator. Type or paste your text, pick a color palette, and get ready-to-use code for per-letter colors, word colors, gradient rainbow headings, animated effects, and PNG images for social media posts.
On this page you will find the online generator, image export options, step-by-step instructions, CSS and JavaScript code examples, a method comparison table, use cases, and frequently asked questions.
Let's look at a few examples rainbow colored text Demo rainbow text
Table of Contents
What is Rainbow Text?
Rainbow text is text where each letter, word, or line uses different colors or a smooth color gradient. It is a popular way to make headings, banners, social posts, and decorative labels stand out without using images.
There are three main approaches to create rainbow text:
- CSS gradient + background-clip - one element with a linear gradient clipped to the text shape.
- HTML spans with inline colors - each letter or word wrapped in a
<span>with its own color. - JavaScript color assignment - a script that splits text and applies HSL colors dynamically.
The generator on this page supports all three output styles. Use the method comparison section below to choose the best approach for your project.
Online Rainbow Text Generator
Use the interactive tool below to create rainbow colored text. The generator produces HTML and CSS you can copy directly into your website, plus optional Google Font links when a web font is selected.
The tool outputs a live preview, a Google Font link (when applicable), and separate HTML and CSS code blocks. Use the copy, run, edit, and download buttons to use the code on your site.
Add your text here
Select a color group
Color Brightness
You can copy and paste this colored text into Google Docs and Gmail Email Compose. But this color text cannot be shared directly to Facebook and Instagram. You need to convert it to an image, below is the option to convert to image format.
Rainbow Text To Image
You can convert this rainbow text into an image in PNG format. You can then easily share this image on your Facebook post or Instagram stories.
Generated HTML CSS code copy and paste it your website.
<div class="rainbow-text">
<span class="block-line"><span><span style="color:#ff0000">H</span><span style="color:#ff5500">T</span><span style="color:#ffaa00">M</span><span style="color:#ffff00">L </span></span><span><span style="color:#aaff00">C</span><span style="color:#55ff00">S</span><span style="color:#00ff00">S </span></span><span><span style="color:#00ff55">R</span><span style="color:#00ffaa">a</span><span style="color:#00ffff">i</span><span style="color:#00aaff">n</span><span style="color:#0055ff">b</span><span style="color:#0000ff">o</span><span style="color:#5500ff">w </span></span><span><span style="color:#aa00ff">T</span><span style="color:#ff00ff">e</span><span style="color:#ff00aa">x</span><span style="color:#ff0055">t</span></span></span>
</div> .rainbow-text {
font-family: Arial Black, Gadget, sans-serif;
font-weight: bold;
text-align: center;
font-size: 50px;
text-shadow: 1px 1px 0px #A3A3A3;
}
.rainbow-text .block-line > span {
display: inline-block;
} How to Use
- Enter your text in the generator text area.
- Choose a color palette (Rainbow, VIBGYOR, Random, Christmas, or Custom).
- Pick a coloring mode: per letter, per word, or gradient (per letter, word, or line).
- Adjust saturation and lightness to get the look you want.
- Set font, size, shadow, stroke, and background as needed.
- Preview the result and refresh colors if you want a new combination.
- Copy the HTML and CSS code, or export as a PNG image for social media.
- Paste the code into your website, document, or upload the image to your post.
Features
- Per-letter and per-word coloring
- Gradient rainbow on letters, words, or lines
- Multiple preset palettes plus custom colors
- Multilingual letter splitting (English, Malayalam, Hindi, Chinese, Bengali, Arabic)
- Google Fonts integration
- Text shadow and stroke (outline) controls
- PNG export with social media size presets
- Copy-paste HTML and CSS code output
- Live preview with refresh controls
- No install or sign-up required
CSS vs HTML vs JavaScript Methods
Choose the right technique based on your needs:
| Method | Best for | Pros | Cons |
|---|---|---|---|
| CSS gradient + background-clip | Headings, static titles | Lightweight, one element, smooth gradient | Not true per-letter colors; limited per-character control |
| HTML spans (tool output) | Any text, multicolor letters | Works everywhere, full color control per character | More HTML markup in the output |
| CSS color animation | Attention-grabbing headings | Pure CSS, no extra HTML | Whole text is one color at a time (cycles through hues) |
| JavaScript RainbowText | Dynamic content, CMS fields | Auto-colors any element text at runtime | Requires JavaScript; re-run when content changes |
CSS Rainbow Gradient Text
Use a CSS linear gradient as the text fill. The gradient is clipped to the text shape with background-clip: text and -webkit-text-fill-color: transparent.
Preview:
<div class="css-rainbow-text">CSS Rainbow Text</div> .css-rainbow-text {
background: linear-gradient(90deg, #f00, #ff2b00, #f50, #ff8000, #fa0, #ffd500, #ff0, #d4ff00, #af0, #80ff00, #5f0, #2bff00, #0f0, #00ff2b, #0f5, #00ff80, #0fa, #00ffd5, #0ff, #00d4ff, #0af, #007fff, #05f, #002bff, #00f, #2a00ff, #50f, #7f00ff, #a0f, #d400ff, #f0f, #ff00d4, #f0a, #ff0080, #f05, #ff002b, #f00);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
background-clip: text;
font-size: 50px;
font-weight: bold;
display: inline-block;
font-family: Arial, Helvetica, sans-serif;
} CSS Animated Rainbow Gradient
Animate the gradient by shifting background-position with a CSS keyframe. The colors smoothly scroll across the text from left to right.
Preview:
<div class="animated-rainbow">Animated Rainbow Gradient</div> .animated-rainbow {
font-size: 42px;
font-family: Arial Black, Gadget, sans-serif;
background: linear-gradient(to left, #f00, #ff2b00, #f50, #ff8000, #fa0, #ffd500, #ff0, #d4ff00, #af0, #80ff00, #5f0, #2bff00, #0f0, #00ff2a, #0f5, #00ff80, #0fa, #00ffd5, #0ff, #00d5ff, #0af, #0080ff, #05f, #002aff, #00f, #2b00ff, #50f, #8000ff, #a0f, #d400ff, #f0f, #ff00d4, #f0a, #ff0080, #f05, #ff002b, #f00);
background-size: 500px 100%;
animation: rainbow-move-left-right 5s linear infinite alternate;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
display: inline-block;
}
@keyframes rainbow-move-left-right {
0% { background-position: 0 0; }
100% { background-position: -500px 0; }
} CSS Animated Rainbow Color
Instead of a gradient, animate the color property through rainbow hues. The entire text cycles through red, orange, yellow, green, blue, indigo, and violet.
Preview:
<div class="animated-rainbow-2">Animated Rainbow Color</div> .animated-rainbow-2 {
font-size: 42px;
font-family: Arial Black, Gadget, sans-serif;
animation: rainbow-color-change 3s linear infinite alternate;
}
@keyframes rainbow-color-change {
0%, 100% { color: #ff0000 }
14% { color: #ff8b00 }
28% { color: #e8ff00 }
42% { color: #5dff00 }
56% { color: #00b9ff }
70% { color: #5d00ff }
84% { color: #e800ff }
} JavaScript Rainbow Text
Use JavaScript when text content changes at runtime and you want each character colored automatically without writing HTML spans by hand. The RainbowText class below splits element text and wraps each character in a colored <span>.
Preview:
<div id="js-rainbow-1">JavaScript Rainbow</div>
<div id="js-rainbow-2">Low Brightness Text</div> #js-rainbow-1, #js-rainbow-2 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 50px;
} class RainbowText {
constructor(elements, saturation = 100, lightness = 50) {
this.saturation = this.clamp(saturation, 20, 100);
this.lightness = this.clamp(lightness, 20, 99);
// script - https://www.html-code-generator.com/html/rainbow-text-generator
const elementArray = elements instanceof NodeList ? Array.from(elements) : [elements];
elementArray.forEach(element => this.applyColor(element));
}
clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
applyColor(element) {
const text = element.textContent;
if (!text) return;
const chars = [...text];
const hueStep = 360 / Math.max(chars.length - 1, 1);
const html = chars.map((char, index) => {
const hue = Math.round(hueStep * index);
const color = `hsl(${hue}, ${this.saturation}%, ${this.lightness}%)`;
const safe = char
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>');
return `<span style="color:${color}">${safe}</span>`;
}).join('');
element.innerHTML = html;
}
} // Usage example:
// default style
new RainbowText(document.getElementById("js-rainbow-1"));
// set color brightness: saturation = 40, lightness = 50
new RainbowText(document.getElementById("js-rainbow-2"), 40, 50); Use Cases
- Website headings and hero banners
- Social media posts and stories (export as PNG)
- Email signatures and newsletter titles
- Discord and chat colorful display names (as image)
- Holiday and event messages (Christmas palette)
- Education and kids alphabet coloring activities
- Logo text and decorative labels on landing pages
Frequently Asked Questions
How do I make each letter a different color?
Use the Rainbow Text Generator tool on this page. Enter your text, choose a color palette, and select Split Letters as the coloring method. The tool wraps each letter in a span with its own color and outputs ready-to-copy HTML and CSS.
Can I use rainbow text on Facebook or Instagram?
Facebook and Instagram do not support pasted HTML colored text in posts. Use the Rainbow Text to Image feature on this page to export your text as a PNG image, then upload that image to your post or story.
Does rainbow text work in Google Docs?
Yes. You can copy the generated HTML rainbow text and paste it into Google Docs or Gmail compose. The per-letter colors are preserved when pasted from the tool output.
What is the difference between gradient and split-letter coloring?
Split-letter coloring assigns a solid color to each individual letter or word using HTML spans. Gradient coloring applies a smooth color transition across letters or words using CSS linear-gradient with background-clip text. Gradient gives a flowing rainbow effect; split-letter gives distinct per-character colors.
Do I need JavaScript for rainbow text?
No. Static rainbow text can be created with HTML spans and CSS alone. JavaScript is only needed when you want to dynamically color text that changes at runtime, such as content loaded from a CMS or user input.
Which browsers support CSS gradient text?
CSS gradient text using background-clip: text works in all modern browsers including Chrome, Firefox, Edge, and Safari. Use -webkit-background-clip and -webkit-text-fill-color for the widest compatibility.
Can I use custom colors?
Yes. In the Rainbow Text Generator, select Custom color as the color group and add your own hex or color values. You can also adjust saturation and lightness to fine-tune the palette.
How do I export rainbow text as an image?
After creating your rainbow text in the generator, open the Rainbow Text to Image section. Choose a preset size such as Instagram Stories, Instagram Post, or Facebook Post, adjust position and padding, then click Update and Download image to save a PNG file.
Does this work with Arabic, Hindi, or other scripts?
Yes. The generator supports letter splitting for English, Malayalam, Hindi, Chinese, Bengali, and Arabic text. Select the appropriate language option in the Letters Splitting panel before generating colors.
Can I animate rainbow text with CSS only?
Yes. You can animate rainbow text with pure CSS using either a moving linear-gradient background or a color property animation that cycles through rainbow hues. Both techniques are demonstrated in the code example sections on this page.