Skip to content

Instantly share code, notes, and snippets.

@ansaso
Last active April 29, 2024 14:59
Show Gist options
  • Save ansaso/accaddab0892a3b47d5f4884fda0468b to your computer and use it in GitHub Desktop.
Save ansaso/accaddab0892a3b47d5f4884fda0468b to your computer and use it in GitHub Desktop.
google calendar color mapping. name (string) to id (integer).

intro

As of 2020-07-27 The default google calendar api response does not include the user visible names:

google calendar color choice.

Below is a json map for all the default colors. Please note:

  • colorId empty for event with default color
  • different colorId for the same color in Calendar and Event (ex. Tomato: 11 and 3)
  • there is no consistent logic in the enumeration of the colors

I am not 100% sure if the colorId's are completely static, as I found an old project in which they were mapped to different numbers.

event colors

{
    "Lavender": 	1,
    "Sage": 		2,
    "Grape": 	    3,
    "Flamingo": 	4,
    "Banana": 		5,
    "Tangerine": 	6,
    "Peacock": 		7,
    "Graphite": 	8,
    "Blueberry": 	9,
    "Basil":        10,
    "Tomato": 		11
}

calendar colors

{
    "Cocoa": 		    1,
    "Flamingo": 	    2,
    "Tomato": 		    3,
    "Tangerine": 	    4,
    "Pumpkin": 		    5,
    "Mango": 		    6,
    "Eucalyptus":       7,
    "Basil": 		    8,
    "Pistachio": 	    9,
    "Avocado": 		    10,
    "Citron": 		    11,
    "Banana": 		    12,
    "Sage": 		    13,
    "Peacock": 		    14,
    "Cobalt": 		    15,
    "Blueberry": 	    16,
    "Lavender": 	    17,
    "Wisteria": 	    18,
    "Graphite": 	    19,
    "Birch": 		    20,
    "beetroot": 	    21,
    "Cherry Blossom": 	22,
    "Grape": 		    23,
    "Amethyst": 	    24

google calendar api response

{
 "kind": "calendar#colors",
 "updated": "2012-02-14T00:00:00.000Z",
 "calendar": {
  "1": {
   "background": "#ac725e",
   "foreground": "#1d1d1d"
  },
  "2": {
   "background": "#d06b64",
   "foreground": "#1d1d1d"
  },
  "3": {
   "background": "#f83a22",
   "foreground": "#1d1d1d"
  },
  "4": {
   "background": "#fa573c",
   "foreground": "#1d1d1d"
  },
  "5": {
   "background": "#ff7537",
   "foreground": "#1d1d1d"
  },
  "6": {
   "background": "#ffad46",
   "foreground": "#1d1d1d"
  },
  "7": {
   "background": "#42d692",
   "foreground": "#1d1d1d"
  },
  "8": {
   "background": "#16a765",
   "foreground": "#1d1d1d"
  },
  "9": {
   "background": "#7bd148",
   "foreground": "#1d1d1d"
  },
  "10": {
   "background": "#b3dc6c",
   "foreground": "#1d1d1d"
  },
  "11": {
   "background": "#fbe983",
   "foreground": "#1d1d1d"
  },
  "12": {
   "background": "#fad165",
   "foreground": "#1d1d1d"
  },
  "13": {
   "background": "#92e1c0",
   "foreground": "#1d1d1d"
  },
  "14": {
   "background": "#9fe1e7",
   "foreground": "#1d1d1d"
  },
  "15": {
   "background": "#9fc6e7",
   "foreground": "#1d1d1d"
  },
  "16": {
   "background": "#4986e7",
   "foreground": "#1d1d1d"
  },
  "17": {
   "background": "#9a9cff",
   "foreground": "#1d1d1d"
  },
  "18": {
   "background": "#b99aff",
   "foreground": "#1d1d1d"
  },
  "19": {
   "background": "#c2c2c2",
   "foreground": "#1d1d1d"
  },
  "20": {
   "background": "#cabdbf",
   "foreground": "#1d1d1d"
  },
  "21": {
   "background": "#cca6ac",
   "foreground": "#1d1d1d"
  },
  "22": {
   "background": "#f691b2",
   "foreground": "#1d1d1d"
  },
  "23": {
   "background": "#cd74e6",
   "foreground": "#1d1d1d"
  },
  "24": {
   "background": "#a47ae2",
   "foreground": "#1d1d1d"
  }
 },
 "event": {
  "1": {
   "background": "#a4bdfc",
   "foreground": "#1d1d1d"
  },
  "2": {
   "background": "#7ae7bf",
   "foreground": "#1d1d1d"
  },
  "3": {
   "background": "#dbadff",
   "foreground": "#1d1d1d"
  },
  "4": {
   "background": "#ff887c",
   "foreground": "#1d1d1d"
  },
  "5": {
   "background": "#fbd75b",
   "foreground": "#1d1d1d"
  },
  "6": {
   "background": "#ffb878",
   "foreground": "#1d1d1d"
  },
  "7": {
   "background": "#46d6db",
   "foreground": "#1d1d1d"
  },
  "8": {
   "background": "#e1e1e1",
   "foreground": "#1d1d1d"
  },
  "9": {
   "background": "#5484ed",
   "foreground": "#1d1d1d"
  },
  "10": {
   "background": "#51b749",
   "foreground": "#1d1d1d"
  },
  "11": {
   "background": "#dc2127",
   "foreground": "#1d1d1d"
  }
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment