Skip to content

Instantly share code, notes, and snippets.

@alvinthen
Created July 29, 2016 17:20
Show Gist options
  • Save alvinthen/a036671f97ea43c6b1f663cf5071b77f to your computer and use it in GitHub Desktop.
Save alvinthen/a036671f97ea43c6b1f663cf5071b77f to your computer and use it in GitHub Desktop.
Convert opacity values in percentage to hexadecimal
0% - 00
1% - 03
2% - 05
3% - 08
4% - 0A
5% - 0D
6% - 0F
7% - 12
8% - 14
9% - 17
10% - 19
11% - 1C
12% - 1F
13% - 21
14% - 24
15% - 26
16% - 29
17% - 2B
18% - 2E
19% - 30
20% - 33
21% - 36
22% - 38
23% - 3B
24% - 3D
25% - 40
26% - 42
27% - 45
28% - 47
29% - 4A
30% - 4D
31% - 4F
32% - 52
33% - 54
34% - 57
35% - 59
36% - 5C
37% - 5E
38% - 61
39% - 63
40% - 66
41% - 69
42% - 6B
43% - 6E
44% - 70
45% - 73
46% - 75
47% - 78
48% - 7A
49% - 7D
50% - 80
51% - 82
52% - 85
53% - 87
54% - 8A
55% - 8C
56% - 8F
57% - 91
58% - 94
59% - 96
60% - 99
61% - 9C
62% - 9E
63% - A1
64% - A3
65% - A6
66% - A8
67% - AB
68% - AD
69% - B0
70% - B3
71% - B5
72% - B8
73% - BA
74% - BD
75% - BF
76% - C2
77% - C4
78% - C7
79% - C9
80% - CC
81% - CF
82% - D1
83% - D4
84% - D6
85% - D9
86% - DB
87% - DE
88% - E0
89% - E3
90% - E6
91% - E8
92% - EB
93% - ED
94% - F0
95% - F2
96% - F5
97% - F7
98% - FA
99% - FC
@joshuamiron
Copy link

joshuamiron commented May 3, 2019

I made a little calculator to do this conversion:

https://www.joshuamiron.com/percent-to-hex-converter

@mandanai
Copy link

mandanai commented Feb 7, 2023

@joshuamiron Web Site has expired

@joshuamiron
Copy link

@joshuamiron Web Site has expired

Yes, I did not renew my web site.

If you want to download a stand-alone html file with the calculator you can do so here:

https://github.com/joshuamiron/Percent-to-Hex-Converter

@mandanai
Copy link

mandanai commented Feb 9, 2023

@joshuamiron Web Site has expired

Yes, I did not renew my web site.

If you want to download a stand-alone html file with the calculator you can do so here:

https://github.com/joshuamiron/Percent-to-Hex-Converter

Many thanks, bro 🙏

@mironjoshua
Copy link

I've turned my website back on, but someone parked on my domain name.

It can now be reached here: https://www.jmiron.com/percent-to-hex-converter

@Pikamander2
Copy link

Pikamander2 commented Oct 16, 2024

Since this is the top result on Google, here's a reversed list that converts 00-FF hex values back to percentages.

(I generated this with ChatGPT and haven't checked the values; don't use it for anything super important)

00 - 0%
01 - 0.39%
02 - 0.78%
03 - 1.18%
04 - 1.57%
05 - 1.96%
06 - 2.35%
07 - 2.75%
08 - 3.14%
09 - 3.53%
0A - 3.92%
0B - 4.31%
0C - 4.71%
0D - 5.10%
0E - 5.49%
0F - 5.88%
10 - 6.27%
11 - 6.67%
12 - 7.06%
13 - 7.45%
14 - 7.84%
15 - 8.24%
16 - 8.63%
17 - 9.02%
18 - 9.41%
19 - 9.80%
1A - 10.20%
1B - 10.59%
1C - 10.98%
1D - 11.37%
1E - 11.76%
1F - 12.16%
20 - 12.55%
21 - 12.94%
22 - 13.33%
23 - 13.73%
24 - 14.12%
25 - 14.51%
26 - 14.90%
27 - 15.29%
28 - 15.69%
29 - 16.08%
2A - 16.47%
2B - 16.86%
2C - 17.25%
2D - 17.65%
2E - 18.04%
2F - 18.43%
30 - 18.82%
31 - 19.22%
32 - 19.61%
33 - 20.00%
34 - 20.39%
35 - 20.78%
36 - 21.18%
37 - 21.57%
38 - 21.96%
39 - 22.35%
3A - 22.75%
3B - 23.14%
3C - 23.53%
3D - 23.92%
3E - 24.31%
3F - 24.71%
40 - 25.10%
41 - 25.49%
42 - 25.88%
43 - 26.27%
44 - 26.67%
45 - 27.06%
46 - 27.45%
47 - 27.84%
48 - 28.24%
49 - 28.63%
4A - 29.02%
4B - 29.41%
4C - 29.80%
4D - 30.20%
4E - 30.59%
4F - 30.98%
50 - 31.37%
51 - 31.76%
52 - 32.16%
53 - 32.55%
54 - 32.94%
55 - 33.33%
56 - 33.73%
57 - 34.12%
58 - 34.51%
59 - 34.90%
5A - 35.29%
5B - 35.69%
5C - 36.08%
5D - 36.47%
5E - 36.86%
5F - 37.25%
60 - 37.65%
61 - 38.04%
62 - 38.43%
63 - 38.82%
64 - 39.22%
65 - 39.61%
66 - 40.00%
67 - 40.39%
68 - 40.78%
69 - 41.18%
6A - 41.57%
6B - 41.96%
6C - 42.35%
6D - 42.75%
6E - 43.14%
6F - 43.53%
70 - 43.92%
71 - 44.31%
72 - 44.71%
73 - 45.10%
74 - 45.49%
75 - 45.88%
76 - 46.27%
77 - 46.67%
78 - 47.06%
79 - 47.45%
7A - 47.84%
7B - 48.24%
7C - 48.63%
7D - 49.02%
7E - 49.41%
7F - 49.80%
80 - 50.20%
81 - 50.59%
82 - 50.98%
83 - 51.37%
84 - 51.76%
85 - 52.16%
86 - 52.55%
87 - 52.94%
88 - 53.33%
89 - 53.73%
8A - 54.12%
8B - 54.51%
8C - 54.90%
8D - 55.29%
8E - 55.69%
8F - 56.08%
90 - 56.47%
91 - 56.86%
92 - 57.25%
93 - 57.65%
94 - 58.04%
95 - 58.43%
96 - 58.82%
97 - 59.22%
98 - 59.61%
99 - 60.00%
9A - 60.39%
9B - 60.78%
9C - 61.18%
9D - 61.57%
9E - 61.96%
9F - 62.35%
A0 - 62.75%
A1 - 63.14%
A2 - 63.53%
A3 - 63.92%
A4 - 64.31%
A5 - 64.71%
A6 - 65.10%
A7 - 65.49%
A8 - 65.88%
A9 - 66.27%
AA - 66.67%
AB - 67.06%
AC - 67.45%
AD - 67.84%
AE - 68.24%
AF - 68.63%
B0 - 69.02%
B1 - 69.41%
B2 - 69.80%
B3 - 70.20%
B4 - 70.59%
B5 - 70.98%
B6 - 71.37%
B7 - 71.76%
B8 - 72.16%
B9 - 72.55%
BA - 72.94%
BB - 73.33%
BC - 73.73%
BD - 74.12%
BE - 74.51%
BF - 74.90%
C0 - 75.29%
C1 - 75.69%
C2 - 76.08%
C3 - 76.47%
C4 - 76.86%
C5 - 77.25%
C6 - 77.65%
C7 - 78.04%
C8 - 78.43%
C9 - 78.82%
CA - 79.22%
CB - 79.61%
CC - 80.00%
CD - 80.39%
CE - 80.78%
CF - 81.18%
D0 - 81.57%
D1 - 81.96%
D2 - 82.35%
D3 - 82.75%
D4 - 83.14%
D5 - 83.53%
D6 - 83.92%
D7 - 84.31%
D8 - 84.71%
D9 - 85.10%
DA - 85.49%
DB - 85.88%
DC - 86.27%
DD - 86.67%
DE - 87.06%
DF - 87.45%
E0 - 87.84%
E1 - 88.24%
E2 - 88.63%
E3 - 89.02%
E4 - 89.41%
E5 - 89.80%
E6 - 90.20%
E7 - 90.59%
E8 - 90.98%
E9 - 91.37%
EA - 91.76%
EB - 92.16%
EC - 92.55%
ED - 92.94%
EE - 93.33%
EF - 93.73%
F0 - 94.12%
F1 - 94.51%
F2 - 94.90%
F3 - 95.29%
F4 - 95.69%
F5 - 96.08%
F6 - 96.47%
F7 - 96.86%
F8 - 97.25%
F9 - 97.65%
FA - 98.04%
FB - 98.43%
FC - 98.82%
FD - 99.22%
FE - 99.61%
FF - 100%

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