Hex alpha to opacity percent
Find the opacity hidden in a hex color: the last pair of #33669980 is 80, which is byte 128 and an opacity of 50.2%, not the 50% many people assume. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Hex
- #33669980
- Alpha hex
- 80
- Alpha byte
- 128
- Opacity percent
- 50.2
This hex alpha to opacity converter reads the final two digits of an eight-digit RRGGBBAA color and turns that byte into a percentage from 0% through 100%. It validates the complete color before calculating anything, accepts an optional leading hash, and reports the normalized color, alpha pair, decimal byte, and opacity percentage. The result is deterministic and consistently rounded to two decimal places, making it suitable for design tokens, CSS reviews, automated migrations, documentation, and tests that need a stable numeric answer rather than a visual estimate.
Read the alpha byte in the correct position
An eight-digit hexadecimal color in CSS order contains four byte pairs: red, green, blue, and alpha. The alpha byte is therefore always the final pair in RRGGBBAA. For example, the pairs in #33669980 are 33, 66, 99, and 80, so 80 is the value this converter uses.
That ordering matters because some graphics tools and older platform formats use AARRGGBB, where alpha appears first. This capability does not guess between conventions or rearrange channels. It deliberately accepts RRGGBBAA only, with or without one leading hash character.
Every one of the eight digits is checked even though only the last two drive the percentage. Validating the entire value prevents a malformed color such as #ZZZZZZ80 from appearing trustworthy merely because its alpha pair happens to be valid. Use a format conversion first if your source stores alpha at the beginning.
What you can do with it
Audit design tokens
Turn embedded alpha bytes into readable percentages while retaining the exact byte for traceability.
Review generated CSS
Confirm that an exported RRGGBBAA color carries the opacity expected by designers and developers.
FAQ
Which eight-digit hex ordering is supported?
The required ordering is RRGGBBAA, with alpha in the final two digits. AARRGGBB is not accepted as a separate convention.
Can I include the leading hash?
Yes. Both #33669980 and 33669980 are valid and produce the same normalized result.
How is the percentage calculated?
The alpha pair is parsed as a byte, divided by 255, multiplied by 100, and rounded to two decimal places.
Why does alpha 80 produce 50.2 instead of 50?
Hex 80 is decimal 128, and 128 divided by 255 is slightly greater than one half. The two-decimal result is 50.2.
What opacity do the alpha pairs 00 and FF give?
00 gives 0%, a fully transparent color, and FF, which is byte 255, gives 100%, a fully opaque one. Every pair in between is divided by 255 and multiplied by 100.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/color/hex-alpha-to-opacity \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"hex":"#33669980"}'const res = await fetch("https://api.kit.forhosting.com/color/hex-alpha-to-opacity", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"hex": "#33669980"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/color/hex-alpha-to-opacity",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"hex": "#33669980"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/color/hex-alpha-to-opacity", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"hex":"#33669980"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"hex":"#33669980"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/color/hex-alpha-to-opacity", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"hex": "#33669980"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "color.hex_alpha_to_opacity",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Read the alpha byte in the correct position
The response includes a lowercase canonical hex value and preserves the extracted pair separately as alpha_hex, making it easy to verify exactly which byte produced the calculation.
Convert a byte to a stable percentage
A hexadecimal byte ranges from 00 through FF, equivalent to decimal values from 0 through 255. The conversion divides the decimal alpha byte by 255 and multiplies the result by 100. For example, an alpha byte of 80 is decimal 128, so it becomes 50.2 rather than an assumed 50. No percent sign is embedded in the numeric field, so the result can be compared, sorted, serialized, or passed directly into further calculations without stripping display text. Opacity uses the same endpoints: byte 0 is fully transparent and byte 255 is fully opaque. Because most intermediate byte values do not map to a terminating decimal percentage, the returned opacity_percent is rounded to two decimal places. This rule is fixed and deterministic: identical input always produces identical JSON, independent of browser locale, current time, network state, or machine settings. The exact alpha_byte remains in the response alongside the rounded percentage, allowing callers to preserve the original eight-bit value when necessary. The special endpoints remain exact: 00 returns 0 and FF returns 100.
Validate inputs and use the result safely
Strict input handling is important when color values flow through design systems, code generators, or stylesheet migrations. The converter rejects missing values, non-string values, the wrong number of hexadecimal digits, and characters outside 0-9 or A-F. Whitespace around a valid string is ignored, and letter case is accepted, but shorthand colors, six-digit RGB colors, multiple hash marks, and alpha-first values are not silently repaired. A rejected value becomes an invalid_input error with a useful message instead of returning a misleading percentage. That behavior lets automated pipelines stop early and show the actual source problem. One API conversion costs $0.002; the pure calculation has no network dependency and can also support immediate browser execution. Treat opacity_percent as the rounded presentation value and alpha_byte as the exact source value whenever a later step needs lossless round-trip behavior.
Integration use cases
Build migration fixtures
Create stable numeric opacity values for tests that migrate eight-digit colors into another representation.
Technical questions
What happens when the color is invalid?
The request returns an invalid_input error describing the missing value, invalid length, type problem, or invalid character.
What does an API conversion cost?
One conversion costs $0.002.