# Gas mileage calculator (MPG calculator)

> Gas mileage calculator: MPG (US and UK), L/100 km and km/L from odometer readings and fuel added, cost per mile, and a fill-up log with trend chart.

Interactive version: https://www.calcopenly.com/everyday/gas-mileage-calculator
Subject: Everyday calculators

Fuel economy is the distance driven divided by the fuel it took to refill the tank. Enter the odometer reading at your last fill-up and today's, or the trip distance, and the gallons or liters you just added. The result is shown as US mpg, UK mpg, L/100 km and km/L, with the fuel cost per mile and per kilometer and the CO₂ the fuel released.

With the defaults, 312 miles on 9.8 gallons is 31.8 mpg. At $4.48 a gallon, the US average for regular in the week of 21 September 2026 (EIA), that tank cost $43.90, or 14.1 cents a mile. The fill-up log takes one line per fill-up and gives the average over all of them, each tank's figure and a trend line.

The method assumes you fill to the same level each time, since a partly filled tank makes one reading high and the next one low. The average of a log is total miles over total fuel, which is not the same as averaging the per-tank mpg.

## Inputs

- **Calculate from** (options: One fill-up, Fill-up log)
- **Distance in** (options: Miles, Kilometers)
- **Fuel in** (options: US gallons, UK gallons, Liters)
- **Distance from** (options: Odometer readings, Trip distance)
- **Odometer at last fill-up**
- **Odometer now**
- **Distance driven**
- **Fuel added to refill the tank**
- **Fill-ups: odometer, fuel added, price**: One fill-up per line, oldest first. The first line is the starting odometer. The price is optional; lines without one use the fuel price below.
- **Fuel price per gallon or liter**: Per unit chosen under “Fuel in”. The default is the EIA US average for regular gasoline, $4.478 a gallon in the week of 21 September 2026.
- **Fuel type (for CO₂)** (options: Gasoline, Diesel)

## Results

- Fuel economy (US) (mpg) — main result
- Fuel economy (UK) (mpg)
- Fuel consumption (L/100 km)
- Kilometers per liter (km/L)
- Distance (mi)
- Distance (km)
- Fuel used (US gal)
- Fuel used (L)
- Fuel cost
- Cost per mile
- Cost per km
- CO₂ from the fuel (kg)
- Best tank
- Worst tank
- Trend per fill-up

## Formula

$$
\text{mpg} = \frac{\text{odometer}_{\text{now}} - \text{odometer}_{\text{last fill}}}{\text{gallons added}},\qquad \text{L/100 km} = \frac{235.215}{\text{mpg (US)}}
$$

## Worked examples

### 312 miles on 9.8 US gallons at $4.48

- Calculate from: One fill-up
- Distance in: Miles
- Fuel in: US gallons
- Distance from: Odometer readings
- Odometer at last fill-up: 24,500
- Odometer now: 24,812
- Fuel added to refill the tank: 9.8
- Fuel price per gallon or liter: 4.48
- **Fuel economy (US): 31.8 mpg**
- **Fuel economy (UK): 38.2 mpg**
- **Fuel consumption: 7.39 L/100 km**
- **Kilometers per liter: 13.54 km/L**
- **Fuel cost: 43.90**
- **Cost per mile: 0.141**
- **CO₂ from the fuel: 87.1 kg**
- Checked against: Python decimal: 312/9.8 = 31.8367 mpg; ×4.54609/3.785411784 = 38.2343 UK mpg; 100×9.8×3.785411784/(312×1.609344) = 7.3882 L/100 km; 9.8×8.887 kg = 87.09 kg (EPA factor)

### fueleconomy.gov worked example

- Calculate from: One fill-up
- Distance in: Miles
- Fuel in: US gallons
- Distance from: Odometer readings
- Odometer at last fill-up: 32,645.1
- Odometer now: 33,001.3
- Fuel added to refill the tank: 13.5
- Fuel price per gallon or liter: 4.48
- **Fuel economy (US): 26.4 mpg**
- **Distance: 356.2 mi**
- Checked against: fueleconomy.gov, Calculate your own gas mileage: 33,001.3 − 32,645.1 = 356.2 miles; 356.2 ÷ 13.5 = 26.4 mpg

### Trip of 520 km on 38.4 liters

- Calculate from: One fill-up
- Distance in: Kilometers
- Fuel in: Liters
- Distance from: Trip distance
- Distance driven: 520
- Fuel added to refill the tank: 38.4
- Fuel price per gallon or liter: 1.85
- **Fuel consumption: 7.38 L/100 km**
- **Kilometers per liter: 13.54 km/L**
- **Fuel economy (US): 31.9 mpg**
- **Fuel cost: 71.04**
- **Cost per km: 0.137**
- Checked against: Python decimal: 38.4×100/520 = 7.3846; 520/38.4 = 13.5417; 235.2145833/7.384615 = 31.8520 US mpg; 38.4×1.85 = 71.04

### UK: 410 miles on 42 liters

- Calculate from: One fill-up
- Distance in: Miles
- Fuel in: Liters
- Distance from: Trip distance
- Distance driven: 410
- Fuel added to refill the tank: 42
- Fuel price per gallon or liter: 1.40
- **Fuel economy (UK): 44.4 mpg**
- **Fuel economy (US): 37.0 mpg**
- **Fuel consumption: 6.37 L/100 km**
- Checked against: Python decimal: 410/(42/4.54609) = 44.3785 UK mpg; 410/(42/3.785411784) = 36.9528 US mpg; 4200/(410×1.609344) = 6.3653

### Default fill-up log

- Calculate from: Fill-up log
- Distance in: Miles
- Fuel in: US gallons
- Fill-ups: odometer, fuel added, price: 24500 / 24812, 9.8, 3.89 / 25105, 9.4, 3.97 / 25421, 10.1, 4.16 / 25730, 9.6, 4.32 / 26…
- Fuel price per gallon or liter: 4.48
- **Fuel economy (US): 31.7 mpg**
- **Distance: 1,546 mi**
- **Fuel used: 48.8 US gal**
- **Best tank: 32.2 mpg**
- **Worst tank: 31.2 mpg**
- **Fuel cost: 203.28**
- **Cost per mile: 0.132**
- **Trend per fill-up: 0.12 mpg**
- Checked against: Python decimal: (26046−24500)/(9.8+9.4+10.1+9.6+9.9) = 1546/48.8; tanks 312/9.8, 293/9.4, 316/10.1, 309/9.6, 316/9.9; cost Σ fuel×price = 203.28; least-squares slope over fill-ups 1–5

### Edge: free fuel and a UK-gallon log with no prices

- Calculate from: Fill-up log
- Distance in: Miles
- Fuel in: UK gallons
- Fill-ups: odometer, fuel added, price: 1000 / 1350, 8
- Fuel price per gallon or liter: 0
- **Fuel economy (UK): 43.8 mpg**
- **Fuel cost: 0.00**
- **Cost per mile: 0.000**
- **Trend per fill-up: not applicable**
- **Best tank: 43.8 mpg (UK)**
- Checked against: Hand calculation: 350 mi ÷ 8 UK gal = 43.75 UK mpg; price 0 gives a cost of 0; one tank has no trend

## Questions

### How do you calculate gas mileage?

Fill the tank and note the odometer. At the next fill-up, subtract the old reading from the new one and divide by the gallons it took to fill the tank again. Driving 312 miles and adding 9.8 gallons gives 312 ÷ 9.8 = 31.8 mpg. The US Department of Energy's fueleconomy.gov uses the same full-tank method in its worked example: 356.2 miles on 13.5 gallons is 26.4 mpg.

### How do you convert mpg to L/100 km?

Divide 235.215 by US mpg, or 282.481 by UK mpg. The constants come from 100 × 3.785411784 L ÷ 1.609344 km for the US gallon and 100 × 4.54609 ÷ 1.609344 for the imperial gallon. So 31.8 US mpg is 7.4 L/100 km, and 7.4 L/100 km is 38.2 UK mpg. Because the relationship is a division, halving L/100 km doubles mpg.

### Why should I average mpg over several fill-ups?

Pumps shut off at slightly different levels, so fuel left out of one fill-up is added at the next, making one tank read high and the next low. fueleconomy.gov warns that an estimate is not accurate unless the tank is filled completely. Dividing the total miles of all fill-ups by their total gallons cancels most of that error. Averaging the per-tank mpg figures instead gives short tanks the same weight as long ones and overstates economy when the tanks vary.

### How much CO₂ does a gallon of gas produce?

Burning one gallon of gasoline produces about 8,887 grams of CO₂, and a gallon of diesel about 10,180 grams, according to the US Environmental Protection Agency. A car averaging 31.8 mpg therefore emits about 280 grams of CO₂ per mile from its tailpipe. EPA's typical passenger vehicle, at 22.2 mpg and 11,500 miles a year, emits about 4.6 metric tons a year. The figure scales with fuel burned, so each mpg gained lowers emissions in proportion.

### What is the cost per mile of driving?

Fuel cost per mile is the price per gallon divided by mpg: $4.48 ÷ 31.8 mpg is 14.1 cents a mile. That covers fuel only. The IRS business standard mileage rate, 76 cents a mile from 1 July 2026 (IR-2026-29), also covers depreciation, insurance, repairs and tires, so it is more than five times the fuel cost of this car.

### How accurate is the gas mileage calculator?

Accuracy depends on your inputs and the method's assumptions. Decimal arithmetic uses 50 significant digits, but estimates, numerical methods and source data can be less precise; the displayed rounding does not remove those limits. It is checked against 6 worked examples whose answers come from independent sources; for example, “312 miles on 9.8 US gallons at $4.48” is checked against Python decimal: 312/9.8 = 31.8367 mpg; ×4.54609/3.785411784 = 38.2343 UK mpg; 100×9.8×3.785411784/(312×1.609344) = 7.3882 L/100 km; 9.8×8.887 kg = 87.09 kg (EPA factor).

### Where does the method come from?

US DOE / EPA fueleconomy.gov — Calculate your own gas mileage (My MPG); NIST SP 811 Appendix B.9 — gallon (US and imperial) and mile conversion factors; US EPA — Greenhouse gas emissions from a typical passenger vehicle (8,887 g CO₂ per gallon of gasoline).

## Sources

- [US DOE / EPA fueleconomy.gov — Calculate your own gas mileage (My MPG)](https://www.fueleconomy.gov/mpg/MPG.do?action=calcMPG)
- [NIST SP 811 Appendix B.9 — gallon (US and imperial) and mile conversion factors](https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b9)
- [US EPA — Greenhouse gas emissions from a typical passenger vehicle (8,887 g CO₂ per gallon of gasoline)](https://www.epa.gov/greenvehicles/greenhouse-gas-emissions-typical-passenger-vehicle)
