How to calculate transaction fees?

How to calculate transaction fees before doing transaction.