How fuel cost is calculated: formulas and assumptions
The formulas and constants behind every calculator on the site, each with a worked example and a source, plus what the results leave out.
On this page
Every calculator here comes down to two steps: work out how much fuel a distance needs, then multiply by what that fuel costs. This page writes out each formula, shows it with numbers, lists every constant we use and where it comes from, and says what the results leave out, so you can check the math yourself.
Last reviewed November 9, 2026.

The core formula
Miles per gallon (mpg) tells you how far a car goes on one gallon, so dividing the distance by it gives the gallons you need. Multiply the gallons by the price per gallon for the cost.
gallons = miles ÷ mpg and cost = gallons × price per gallon
Worked example (made-up numbers)
240 miles at 30 mpg is 240 ÷ 30 = 8 gallons. At $3.50 a gallon that is 8 × 3.50 = $28.00.
The fuel cost calculator and the trip gas calculator run exactly this.
Finding your mpg
Every example here starts from an mpg figure. To get one that reflects your driving, fill the tank, note the odometer, drive as you normally do, then refill and note how many gallons it took. Divide the miles driven by the gallons added.
mpg = miles since last fill-up ÷ gallons added at the next fill-up
312 miles ÷ 10.4 gallons = 30 mpg. In L/100km that is 235.215 ÷ 30 = 7.8 (see the conversion below). The fuel consumption calculator does this for you.
Cost per mile
Cost per mile is the price per gallon divided by mpg. The distance cancels out, so it holds for any trip length.
fuel cost per mile = price per gallon ÷ mpg
$3.50 ÷ 30 mpg = $0.1167, about 11.7 cents a mile. This is fuel only; the cost per mile calculator can add other running costs.
Round trips and splitting the cost
A round trip doubles the distance before you apply the formula. To split the cost, divide the total by the number of people sharing, which assumes an equal split.
A 240-mile trip each way is 480 miles. At 30 mpg that is 16 gallons, or $56.00 at $3.50. Shared between 4 people it is $14.00 each.
Yearly and monthly cost
Use yearly miles in place of trip miles, then divide the yearly cost by twelve for a monthly figure. That assumes you drive about the same distance every month.
12,000 miles ÷ 30 mpg = 400 gallons. At $3.50 that is $1,400 a year, or $116.67 a month. The monthly fuel cost calculator works from your weekly miles and the weeks you drive per year.
Converting mpg to L/100km
US mpg and liters per hundred kilometers (L/100km) measure the same thing from opposite ends, so one is a constant divided by the other. The constants come from the NIST Guide to the SI, Appendix B (gallon, mile): one US gallon is 3.785 412 liters, and one mile is exactly 1.609 344 kilometers.
L/100km = 100 × 3.785412 ÷ (1.609344 × mpg) = 235.215 ÷ mpg (our derivation from the two factors above)
At 30 mpg: 235.215 ÷ 30 = 7.84, shown as 7.8 L/100km.
The MPG to L/100km converter works both ways, and the fuel consumption calculator also shows L/100km. The constants here are for US gallons. Imperial gallons are a different size.
Electric cars: kWh per hundred miles and MPGe
MPGe (miles per gallon equivalent) rates an electric car against gasoline by treating a gallon of gasoline as 33.7 kWh of energy. The U.S. Department of Energy's fueleconomy.gov lists 1 gallon of gasoline as 33.7 kWh, and AAA's explainer what MPGe is and how it is derived multiplies miles per kWh by 33.7 to get MPGe. Turned around, electricity use is:
kWh per 100 miles = 33.7 × 100 ÷ MPGe, and EV cost per mile = kWh per 100 miles ÷ 100 × price per kWh
A car rated 120 MPGe uses 3,370 ÷ 120 = 28.08 kWh per 100 miles. At $0.16 per kWh that is $0.045 a mile, or about $539 over 12,000 miles. The EV vs gas cost calculator sets this beside a gas car.
Constants used across the site
| Constant | Value | Used for | Source |
|---|---|---|---|
| Liters per US gallon | 3.785 412 | mpg and L/100km | NIST Guide to the SI, Appendix B |
| Kilometers per mile | 1.609 344 (exact) | mpg and L/100km | NIST Guide to the SI, Appendix B |
| mpg and L/100km constant | 235.215 | Converter, fuel consumption | Derived from the two rows above |
| kWh per gallon of gasoline | 33.7 | MPGe to electricity use | fueleconomy.gov, AAA |
The calculators apply only the constants in this table to the numbers you enter.
Why no gas prices are filled in
Prices change by state, station and day, and we do not look them up, so any figure we filled in would be a guess presented as fact. Some fields start with a value labelled as an example. Others start empty. Replace the example with the price you actually pay, because the result is only as good as that input.
What the results leave out
Each result is a single estimate from the numbers you give it. It does not include:
- Traffic, stop-and-go driving and idling.
- Speed, which changes how much fuel a car uses.
- Load, such as passengers, cargo, roof boxes or a trailer.
- Weather, including cold, wind, hills and air conditioning.
- Tolls, parking, and non-fuel running costs such as tires and maintenance.
- Detours and the miles to and from the pump.
The more your real driving differs from the mpg you enter, the further the result will be off. For a walk-through of estimating one trip, see how much gas you will use on a trip.
Sources
- NIST Guide to the SI, Appendix B: conversion factors
- fueleconomy.gov, U.S. Department of Energy
- AAA, what MPGe is and how it is derived
Spotted a mistake? Tell us through the contact page. More about the site is on the about page.