{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiaihx4wihvv66gkx32o45tsr7mnixet66gpn4y2p4eftvkiao3omm",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mpn5e3qhf3d2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreieaumncahxrzxbgi3rdf33z6wdniurekzmacurjolvbaejnmip2de"
},
"mimeType": "image/webp",
"size": 72804
},
"path": "/dev_nestio_229945f10652e4/ansi-color-code-generator-build-terminal-escape-sequences-visually-287k",
"publishedAt": "2026-07-02T03:36:01.000Z",
"site": "https://dev.to",
"tags": [
"webdev",
"devtools",
"terminal",
"javascript",
"ANSI Color Code Generator ā DevNestio",
"DevNestio"
],
"textContent": "Stop memorizing ANSI escape sequences. I built a browser tool to generate them visually ā pick colors, styles, and get the code ready to paste.\n\n## Try it\n\nš ANSI Color Code Generator ā DevNestio\n\n## Features\n\n * **3 color modes** : 8-color, 256-color palette, RGB truecolor (24-bit)\n * **8 text styles** : Bold, Dim, Italic, Underline, Blink, Reverse, Hidden, Strikethrough\n * **Separate FG/BG** : Set foreground and background colors independently\n * **3 output formats** : Shell (`echo -e`), Python (`print`), Raw escape sequence\n * **Live preview** in a simulated terminal box\n\n\n\n## How ANSI sequences work\n\n\n ESC [ <codes> m\n\n\nMultiple codes are separated by `;`. Reset is `ESC[0m`.\n\n**8-color** : codes 30-37 (FG), 40-47 (BG), 90-97 (bright FG)\n\n**256-color** : `ESC[38;5;<0-255>m` for FG, `ESC[48;5;<0-255>m` for BG\n\n**RGB truecolor** : `ESC[38;2;<R>;<G>;<B>m`\n\n## 256-color palette calculation\n\n\n function get256Color(i) {\n if (i < 16) return standardColors[i].hex;\n if (i < 232) {\n const n = i - 16;\n const r = Math.floor(n / 36) * 51; // 255/5 = 51\n const g = Math.floor((n % 36) / 6) * 51;\n const b = (n % 6) * 51;\n return `rgb(${r},${g},${b})`;\n }\n const v = (i - 232) * 10 + 8; // 24 grayscale steps\n return `rgb(${v},${v},${v})`;\n }\n\n\n## Output examples\n\n\n # Bold red text on black\n echo -e \"\\e[1;31mHello, Terminal!\\e[0m\"\n\n # RGB orange (Python)\n print(\"\\033[38;2;255;128;0mOrange text\\033[0m\")\n\n\nTested with 128 assertions covering code generation, color math, and format strings.\n\nPart of DevNestio ā 115 free browser-only developer tools.",
"title": "ANSI Color Code Generator: Build Terminal Escape Sequences Visually"
}