For legacy, it's straightforward: feerate multiplied by the transaction's size.
Eg. A typical 1 input - 2 outputs transaction with a total of approx 250Bytes data will use a fee rate of 1sat/B = 250satoshi (
0.00000250BTC) fee.
For SegWit, you'll have to compute the Weight which is the Raw Byte of non-Witness data multiplied by four and Raw Byte of Witness data multiplied by one.
Then, 1/4 of the weight is the vByte (
virtual Bytes) which will be used to compute the total fee instead of the total size in disk.
Eg. A 1 input P2SH-SegWit - 2 outputs transaction with an approx total of 166 vBytes at 1sat/B = will pay 166satoshi (
0.00000166BTC) fee
Wallets supporting SegWit (
Electrum for example), will automatically use the vByte as "
Size" instead of the raw bytes (
so don't stress out the computation).
Use
Blockstream blockexplorer to see the exact values, blockchain.com's size is incorrect.