Open this example in the interactive library
Source code
const hex = "00a3ff";
if (!/^(?:[0-9a-f]{2})*$/i.test(hex)) throw new TypeError("Invalid hex");
console.log([
...Uint8Array.from(hex.match(/../g) ?? [], (byte) =>
Number.parseInt(byte, 16),
),
]);
Sample output
[ 0, 163, 255 ]
