How the cost is calculated
Three steps. The distance is converted to kilometres and the fuel economy to kilometres per litre, and one divided by the other is the litres of fuel the journey burns. The price is converted to a price per litre. Litres times price per litre is the cost. Every conversion uses the exact definitions of the mile (1.609344 km), the US gallon (3.785411784 litres) and the imperial gallon (4.54609 litres), the same constants the converters on this site run on.
The cost per mile or per kilometre is the total divided by the distance, and it is the most useful number here when comparing two cars: multiply it by your annual mileage and the difference between the cars is the yearly saving. The 'per year' switch does that multiplication for you if you enter your annual distance.
Choosing the right fuel economy figure
The result is only as good as the economy figure you put in. Official ratings are laboratory results and real driving uses more fuel: for a WLTP figure, knock off 15 to 20% before entering it; an EPA figure can go in as it is; an Indian ARAI or older NEDC figure needs 20% or more taken off. The real-world MPG guide explains why and by how much.
Better still, measure your own. Two receipts and an odometer reading give a figure that describes your car and your driving, and the MPG calculator turns them into every unit this page accepts. A measured 27 mpg entered here will predict a fuel bill far more accurately than the sticker's 32.
The US and UK gallon, again
Fuel prices per gallon and fuel economy in mpg both depend on which gallon is meant, and mixing them up produces a cost that is 20% wrong. A British driver who enters imperial mpg and a price per US gallon, or the reverse, will get a bad answer. The unit selectors on each input exist so that the calculator does the reconciling; pick the gallon each figure actually came from. Where the fuel is sold by the litre, as it is almost everywhere outside the United States, enter the price per litre and let the calculator handle the rest.
What the CO2 figure means
Burning a litre of petrol releases roughly 2.31 kg of carbon dioxide and a litre of diesel roughly 2.68 kg, because diesel is denser and carries more carbon per litre. The calculator multiplies the litres burned by the factor for the fuel you select, and divides by the distance for a grams-per-kilometre figure comparable with the official CO2 rating on a European spec sheet. It is a tailpipe figure and leaves out the emissions of refining and transporting the fuel, which add around 20% on a full life-cycle basis.
Diesel's higher factor per litre is partly offset by its better economy, which is why a diesel car's CO2 per kilometre is usually lower than a petrol equivalent's despite the heavier fuel. The calculator makes that trade-off visible: enter the two cars' economy figures with the matching fuel type and compare the g/km.