Enter the distance, fuel economy and gas price. The calculator finds the fuel you need (liters) and the fuel cost.
Table of Contents
-
What you can do on this page
-
What is this calculation used for?
-
How to Use
-
Formula
-
Symbols and terms
-
Good to know before you start
-
How to calculate it in Excel
-
How to calculate it in Google Sheets
-
How to calculate it in Python
-
How to write it in LaTeX and other math languages (copy and paste)
-
How to have ChatGPT do the calculation
-
DataChef Features
-
Related Features
-
NumberChef Calculators List
What you can do on this page
- Enter the distance (miles), fuel economy and gas price ($ per gallon), and you get the gallons of gas you need and the fuel cost on the spot
- Fuel economy can be entered in mpg (miles per gallon) or in gallons per 100 miles, the two numbers on the EPA fuel economy label. Switch "Units" to Metric to use km, km/L or L/100km and $ per liter
- A comparison table shows how the cost changes if your fuel economy is better or worse than now (5 levels)
- A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
What is this calculation used for?
Driving 400 miles in a car that gets 25 mpg with gas at $3.20 a gallon takes about 16 gallons of gas, about $51.20. The round trip is about $102.40.
Add tolls and parking, and you can estimate the total before you leave. This makes planning a trip budget easier, and you can compare driving with flying or taking the train using real numbers instead of a guess.
A 15-mile commute each way for 20 workdays a month is 600 miles a month. At 25 mpg and $3.20 a gallon, that is 24 gallons, about $76.80 a month, or about $921.60 a year.
It is money that goes out almost every month, so putting a correct estimate in your budget as a regular expense makes managing your money easier.
If you drive 12,000 miles a year and switch from a 20 mpg car to a 40 mpg car, the gas you use drops by half, from 600 gallons to 300 gallons. At $3.20 a gallon, that saves about $960 a year.
Hybrids and other fuel-efficient cars often cost more to buy, so being able to calculate "how many years it takes to earn back the price gap through lower gas costs" is a big help when choosing a car (the real difference depends on your real-world mpg and driving).
For a 50-mile trip each way, a 25 mpg car at $3.20 a gallon uses about $6.40 of gas one way. Compare that with the train or bus fare, and you can see right away which is cheaper.
When several people ride together, the car's cost can be split among them, but a car also has parking fees and tolls. Getting the gas cost right is the starting point for this kind of comparison.
A work car that is driven 2,000 miles a month at 25 mpg uses 80 gallons of gas, about $256 a month at $3.20 a gallon.
In trucking, delivery, sales and other jobs that depend on driving, this calculation is the base for operating costs and pricing. Keep in mind that the IRS standard mileage rate for business driving (70 cents per mile for 2025) covers more than gas: it also includes wear, maintenance, insurance and depreciation.
Formula
Symbols and terms
Symbols
| \(d\) | Distance. How far you drive, in miles. It is the first letter of "distance". |
| \(e\) | Fuel economy, in mpg (miles per gallon) or in gallons per 100 miles. It is the first letter of "efficiency". |
| \(F\) | Fuel needed. The amount of gas the trip takes, in gallons. It is the first letter of "fuel". |
| \(u\) | Gas price. The price of 1 gallon of gas ($ per gallon). It is the first letter of "unit price". |
| \(C\) | Fuel cost ($). It is the first letter of "cost". |
Terms
| fuel economy | How efficiently a car uses fuel. In the US it is usually written as miles per gallon (mpg); the larger the number, the farther the car goes on less gas. It is also called gas mileage. |
| mpg (miles per gallon) | The unit of fuel economy that tells how many miles a car goes on 1 gallon of gas. It is the number used on US window stickers and in everyday talk. The larger the number, the better the fuel economy. (In Japan, km/L is used the same way.) |
| gal/100mi (gallons per 100 miles) | The unit of fuel economy that tells how many gallons it takes to drive 100 miles. It appears on the EPA label next to mpg. Unlike mpg, a smaller number means better fuel economy. Europe, Canada and Australia use the metric version, L/100km. |
| EPA rating | The official fuel economy on a new car's window sticker (the Fuel Economy and Environment Label). It comes from standard EPA tests and is shown as city, highway and combined mpg. Real driving often gives lower numbers. |
| real-world fuel economy | The fuel economy you actually get. It changes with road conditions, driving style, air conditioning, passengers and so on, and is often lower than the EPA rating. You can work it out yourself from the miles driven and the gallons you put in. |
| gallon (gal) | A unit of volume. In the US, gas is sold by the gallon, and the pump shows how many gallons you put in. One US gallon is about 3.785 liters. |
Good to know before you start
Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back to these topics is the quickest way forward.
| Division and decimals (Grades 4–5) |
|
| Unit rates (Grade 6) |
|
| Proportional relationships (Grades 6–7) |
|
| Reading units (elementary to middle school) |
|
How to calculate it in Excel
| Distance (mi) | 300 |
| Fuel economy (mpg) | 25 |
| Fuel needed (gal) | =B1/B2 |
| Distance (mi) | 500 |
| Fuel economy (gal/100mi) | 4 |
| Fuel needed (gal) | =B1*B2/100 |
| Fuel needed (gal) | 12 |
| Gas price ($/gal) | 3.20 |
| Fuel cost ($) | =B1*B2 |
The first table is the example of 300 miles at 25 mpg, and B3 shows 12 (gallons). The second table is for fuel economy in gallons per 100 miles, and B3 shows 20 (gallons).
The third table multiplies the fuel needed by the price, and B3 shows 38.4 ($38.40). Just replace B1 and B2 with your own numbers.
How to calculate it in Google Sheets
| Distance (mi) | 300 |
| Fuel economy (mpg) | 25 |
| Fuel needed (gal) | =B1/B2 |
| Distance (mi) | 500 |
| Fuel economy (gal/100mi) | 4 |
| Fuel needed (gal) | =B1*B2/100 |
| Fuel needed (gal) | 12 |
| Gas price ($/gal) | 3.20 |
| Fuel cost ($) | =B1*B2 |
How to calculate it in Python
distance_mi = 300 # distance (miles)
efficiency_mpg = 25 # fuel economy (mpg)
price_per_gal = 3.20 # gas price ($ per gallon)
# fuel needed (gal) = distance ÷ fuel economy (mpg)
fuel_gal = distance_mi / efficiency_mpg
# fuel cost ($) = fuel needed × price
cost = fuel_gal * price_per_gal
print(f"Fuel needed: {fuel_gal:.2f} gal")
print(f"Fuel cost: ${cost:.2f}")
# if your fuel economy is in gallons per 100 miles, use this line instead
# fuel_gal = distance_mi * efficiency_gal_per_100mi / 100
How to write it in LaTeX and other math languages (copy and paste)
F = d ÷ e
F = \frac{d}{e}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>F</mi>
<mo>=</mo>
<mfrac><mi>d</mi><mi>e</mi></mfrac>
</mrow>
</math>
F = d / e
fuel = distance/efficiency
F := d/e;
F = d/e;
F = d/e
F = d × e ÷ 100
F = \frac{d \times e}{100}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>F</mi>
<mo>=</mo>
<mfrac>
<mrow><mi>d</mi><mo>×</mo><mi>e</mi></mrow>
<mn>100</mn>
</mfrac>
</mrow>
</math>
F = (d * e) / 100
fuel = distance*efficiency/100
F := d*e/100;
F = d*e/100;
F = d×e/100
C = F × u
C = F \times u
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>C</mi>
<mo>=</mo>
<mi>F</mi>
<mo>×</mo>
<mi>u</mi>
</mrow>
</math>
C = F * u
cost = fuel*price
C := F*u;
C = F*u;
C = F×u
How to have ChatGPT do the calculation
You are a gas cost calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing). A car that gets 25 mpg is driven 300 miles. The gas price is $3.20 per gallon. Find the gallons of gas needed with "distance (miles) ÷ fuel economy (mpg)". Find each of the following: 1. The gallons of gas needed 2. The fuel cost ($) 3. The fuel cost for the round trip (600 miles) ($) Show the formulas you used and the numbers from the execution result.
How to Use
-
1Enter your numbersType the numbers you want to calculate with into the input fields
-
2CalculatePress the "Calculate" button
-
3Check the resultThe result appears on the spot. The same page also explains the idea behind the calculation and the formula
DataChef Features
No technical knowledge required.
Intuitive and user-friendly operation.
Can be used without registering personal information.
Automatic file deletion by clicking "download".
and rapid file conversion.
No attribution required.
No need to contact us for commercial use permission.
