Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Last active August 11, 2025 17:37
Show Gist options
  • Save jasonm23/2868981 to your computer and use it in GitHub Desktop.
Save jasonm23/2868981 to your computer and use it in GitHub Desktop.
Xterm 256color mode color chart, organised into sections. (used on Wikipedia/xterm)
# render as two 8 cell rows
---
:xterm16:
- "000,000000"
- "001,800000"
- "002,008000"
- "003,808000"
- "004,000080"
- "005,800080"
- "006,008080"
- "007,c0c0c0"
- "008,808080"
- "009,ff0000"
- "010,00ff00"
- "011,ffff00"
- "012,0000ff"
- "013,ff00ff"
- "014,00ffff"
- "015,ffffff"
# render as two 12 cell rows
:xtermGreyscale:
- "232,080808"
- "233,121212"
- "234,1c1c1c"
- "235,262626"
- "236,303030"
- "237,3a3a3a"
- "238,444444"
- "239,4e4e4e"
- "240,585858"
- "241,626262"
- "242,6c6c6c"
- "243,767676"
- "255,eeeeee"
- "254,e4e4e4"
- "253,dadada"
- "252,d0d0d0"
- "251,c6c6c6"
- "250,bcbcbc"
- "249,b2b2b2"
- "248,a8a8a8"
- "247,9e9e9e"
- "246,949494"
- "245,8a8a8a"
- "244,808080"
# render as 3 table blocks.
# each block rendered top -> bottom, left -> right
# 6 cells down, 12 cells across. (modular arithmetic time!)
:xterm256:
- "016,000000"
- "017,00005f"
- "018,000087"
- "019,0000af"
- "020,0000d7"
- "021,0000ff"
- "022,005f00"
- "023,005f5f"
- "024,005f87"
- "025,005faf"
- "026,005fd7"
- "027,005fff"
- "028,008700"
- "029,00875f"
- "030,008787"
- "031,0087af"
- "032,0087d7"
- "033,0087ff"
- "034,00af00"
- "035,00af5f"
- "036,00af87"
- "037,00afaf"
- "038,00afd7"
- "039,00afff"
- "040,00d700"
- "041,00d75f"
- "042,00d787"
- "043,00d7af"
- "044,00d7d7"
- "045,00d7ff"
- "046,00ff00"
- "047,00ff5f"
- "048,00ff87"
- "049,00ffaf"
- "050,00ffd7"
- "051,00ffff"
- "082,5fff00"
- "083,5fff5f"
- "084,5fff87"
- "085,5fffaf"
- "086,5fffd7"
- "087,5fffff"
- "076,5fd700"
- "077,5fd75f"
- "078,5fd787"
- "079,5fd7af"
- "080,5fd7d7"
- "081,5fd7ff"
- "070,5faf00"
- "071,5faf5f"
- "072,5faf87"
- "073,5fafaf"
- "074,5fafd7"
- "075,5fafff"
- "064,5f8700"
- "065,5f875f"
- "066,5f8787"
- "067,5f87af"
- "068,5f87d7"
- "069,5f87ff"
- "058,5f5f00"
- "059,5f5f5f"
- "060,5f5f87"
- "061,5f5faf"
- "062,5f5fd7"
- "063,5f5fff"
- "052,5f0000"
- "053,5f005f"
- "054,5f0087"
- "055,5f00af"
- "056,5f00d7"
- "057,5f00ff"
- "093,8700ff"
- "092,8700d7"
- "091,8700af"
- "090,870087"
- "089,87005f"
- "088,870000"
- "099,875fff"
- "098,875fd7"
- "097,875faf"
- "096,875f87"
- "095,875f5f"
- "094,875f00"
- "105,8787ff"
- "104,8787d7"
- "103,8787af"
- "102,878787"
- "101,87875f"
- "100,878700"
- "111,87afff"
- "110,87afd7"
- "109,87afaf"
- "108,87af87"
- "107,87af5f"
- "106,87af00"
- "117,87d7ff"
- "116,87d7d7"
- "115,87d7af"
- "114,87d787"
- "113,87d75f"
- "112,87d700"
- "123,87ffff"
- "122,87ffd7"
- "121,87ffaf"
- "120,87ff87"
- "119,87ff5f"
- "118,87ff00"
- "159,afffff"
- "158,afffd7"
- "157,afffaf"
- "156,afff87"
- "155,afff5f"
- "154,afff00"
- "153,afd7ff"
- "152,afd7d7"
- "151,afd7af"
- "150,afd787"
- "149,afd75f"
- "148,afd700"
- "147,afafff"
- "146,afafd7"
- "145,afafaf"
- "144,afaf87"
- "143,afaf5f"
- "142,afaf00"
- "141,af87ff"
- "140,af87d7"
- "139,af87af"
- "138,af8787"
- "137,af875f"
- "136,af8700"
- "135,af5fff"
- "134,af5fd7"
- "133,af5faf"
- "132,af5f87"
- "131,af5f5f"
- "130,af5f00"
- "129,af00ff"
- "128,af00d7"
- "127,af00af"
- "126,af0087"
- "125,af005f"
- "124,af0000"
- "160,d70000"
- "161,d7005f"
- "162,d70087"
- "163,d700af"
- "164,d700d7"
- "165,d700ff"
- "166,d75f00"
- "167,d75f5f"
- "168,d75f87"
- "169,d75faf"
- "170,d75fd7"
- "171,d75fff"
- "172,d78700"
- "173,d7875f"
- "174,d78787"
- "175,d787af"
- "176,d787d7"
- "177,d787ff"
- "178,dfaf00"
- "179,dfaf5f"
- "180,dfaf87"
- "181,dfafaf"
- "182,dfafdf"
- "183,dfafff"
- "184,dfdf00"
- "185,dfdf5f"
- "186,dfdf87"
- "187,dfdfaf"
- "188,dfdfdf"
- "189,dfdfff"
- "190,dfff00"
- "191,dfff5f"
- "192,dfff87"
- "193,dfffaf"
- "194,dfffdf"
- "195,dfffff"
- "226,ffff00"
- "227,ffff5f"
- "228,ffff87"
- "229,ffffaf"
- "230,ffffdf"
- "231,ffffff"
- "220,ffdf00"
- "221,ffdf5f"
- "222,ffdf87"
- "223,ffdfaf"
- "224,ffdfdf"
- "225,ffdfff"
- "214,ffaf00"
- "215,ffaf5f"
- "216,ffaf87"
- "217,ffafaf"
- "218,ffafdf"
- "219,ffafff"
- "208,ff8700"
- "209,ff875f"
- "210,ff8787"
- "211,ff87af"
- "212,ff87df"
- "213,ff87ff"
- "202,ff5f00"
- "203,ff5f5f"
- "204,ff5f87"
- "205,ff5faf"
- "206,ff5fdf"
- "207,ff5fff"
- "196,ff0000"
- "197,ff005f"
- "198,ff0087"
- "199,ff00af"
- "200,ff00df"
- "201,ff00ff"
@davidchambers
Copy link

The (r, g, b) tuples of the xterm256 hex codes are the product of {0, 95, 135, 175, 215, 255}. There are 6^3 tuples. The pattern is broken towards the end, though, with 223 appearing in place of 215. You have xterm 200, for example, as '#ff00df'/(255, 0, 223). Should this actually be '#ff00d7'/(255, 0, 215) or does the pattern actually switch from 215 to 223 at some point?

@felixrabe
Copy link

See also https://github.com/sindresorhus/xterm-colors which uses d7 instead of df throughout. (Disclaimer: I'm just a random visitor Googl/DDGing around and have no clue whatsoever.)

@felixrabe
Copy link

After more digging – the df values are indeed wrong.

See the xterm source at https://invisible-island.net/xterm/#download, file 256colres.pl, which contains the formula for the sequence of color values used in xterm for each of the R/G/B components: (0=00, 95=5f, 135=87, 175=af, 215=d7, 255=ff).

@mfurquimdev
Copy link

Well, if that's the case, this command might do the trick:
$ sed -i -e 's,df,d7,g' xterm-256color.yaml

@jasonm23
Copy link
Author

Hi all, Please consider donating to this or any of my many of opensource projects.

Buy Me a Coffee at ko-fi.com

@scarlion1
Copy link

Not until you correct your chart and the information Wikipedia is showing the world 😜

@jasonm23
Copy link
Author

@scarlion1 as far as I know it's correct. I would happily correct any errors. @davidchambers didm't cite a reference just noticed the pattern is a bit, inconsistent. (It's why I provided the unrolled sequence instead of providing a generator to compute it.)

I grabbed a link for https://github.com/joejulian/xterm/blob/master/256colres.h I'll cross check it today.

@jasonm23
Copy link
Author

Welp, looks like there's at least one error, @scarlion1, @davidchambers. Updating shortly.

@jasonm23
Copy link
Author

@mfurquimdev @felixrabe - thanks for those corrections.

@jasonm23
Copy link
Author

Updated on https://en.wikipedia.org/wiki/Xterm thanks all.

@scarlion1
Copy link

Good boy 🫳
I gib coffee β˜•β˜•β˜•β˜•

@jasonm23
Copy link
Author

@scarlion1 hah! Thanks, I thought you were joking ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment