A Bitcoin transaction can occupy 201 bytes in a file and have a virtual size of 126 vbytes. Both figures can be correct. Bitcoin virtual size measures a transaction’s use of the block weight budget. To work it out, you need to know how much of the transaction belongs to its base serialization.

On this page
Start with the two byte counts
Imagine a transaction with a base size of 100 bytes and a total size of 201 bytes. These are illustrative numbers. Base size is what remains when the transaction is serialized without witness-related data. Total size includes the full serialization. The 100 base bytes are already included in the 201. Adding the two numbers together would count them twice without producing a useful measure.
Segregated Witness, usually shortened to SegWit, gives witness information a separate place in the transaction format. This can include signatures needed to validate a spend. The accounting rule gives different weight to the base portion and the additional serialized data. The amount of bitcoin being sent does not enter the formula.
Calculate Bitcoin virtual size from bytes and weight
BIP 141 defines transaction weight as three times the base size plus the total size. For our example, three times 100 plus 201 gives 501 weight units. Another way to check the same result is to count each base byte four times, then add the remaining 101 bytes once. That gives 400 plus 101.
Divide the weight by four and round upward to the next whole virtual byte when there is a remainder. Here, 501 divided by four is 125.25, so the transaction measures 126 vbytes. At exactly 500 weight units, the result would be 125 vbytes. Keep the original precision until this last step.
Compare two transactions with the same file size
Consider another example with the same total size of 201 bytes and a base size of 120. Its weight is 3 × 120 + 201, or 561 units. Its virtual size is 141 vbytes after rounding. Replacing 20 bytes of the additional portion with 20 base bytes has added 60 units of weight while leaving the total byte count unchanged.
This also explains a familiar special case. If base and total size are identical, a 200-byte transaction weighs 800 units and measures 200 vbytes. Bytes and virtual bytes happen to agree because every byte in this example gets the same weight.
Check a Bitcoin virtual size figure in reverse
If all you have is a displayed virtual size of 126 vbytes, can you recover the weight? Only within a narrow range. Any whole-number weight from 501 to 504 units rounds up to 126 vbytes. A weight of 500 yields 125, while 505 yields 127. This is why multiplying the displayed virtual size by four does not always recover the precise weight. It gives the upper end of the range. If two transaction viewers appear to disagree by one or two weight units, compare the actual weight fields before comparing a number reconstructed from the rounded display.
Read the unit beside the number
When comparing transaction records, look for the labels size, weight and vsize. If an explorer gives only total size, you still need weight or base size to reproduce the virtual size. If it gives weight, division by four and the final rounding are enough. You can check the arithmetic on a published transaction without connecting a wallet.
The definitions and the four-million-unit block weight limit are in BIP 141, Segregated Witness, particularly “Block size” and “Transaction size calculations.” For more protocol reading, see Fradiqueland’s listening guide to Bitcoin Optech 430.