Quick answer
Trip fuel cost is distance divided by fuel economy, times the price per gallon: 300 miles at 30 mpg uses 10 gallons, which at $3.50 a gallon costs $35.00, or about $0.12 per mile. The price is the one you type in; the calculator does not look up current prices.
The calculator works in miles, miles per US gallon and dollars per US gallon, so convert kilometres and litres first. For a round trip, enter double the one-way distance.
Related tools: Fuel Savings Calculator: Yearly fuel savings from a more efficient vehicle. MPG Calculator: Miles per gallon from distance and fuel used. Distance per Tank Calculator: Range on a full tank from tank size and fuel economy.
How to use the Fuel Cost Calculator
- Enter distance (miles) (above 0).
- Enter fuel economy (mpg) (above 0).
- Enter fuel price ($ per gallon) (0 or more).
- Press Calculate to see the result, and use Reset to start again.
| Input | What to enter | Allowed values |
|---|---|---|
| Distance | A number, in miles | > 0 |
| Fuel economy | A number, in mpg | > 0 |
| Fuel price | A number, in $ per gallon | ≥ 0 |
Formula and method
Formula
cost = distance ÷ mpg × price per gallon
IEEE-754 double precision; shown to at most 6 decimal places.
US gallons and miles.
Worked examples
These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.
Example 1
Inputs: Distance = 300; Fuel economy = 30; Fuel price = 3.5.
| Result | Value |
|---|---|
| Trip cost | $35.00 |
| Fuel needed | 10 gal |
| Cost per mile | $0.12 |
Example 2
Inputs: Distance = 120; Fuel economy = 25; Fuel price = 4.
| Result | Value |
|---|---|
| Trip cost | $19.20 |
| Fuel needed | 4.8 gal |
| Cost per mile | $0.16 |
The first line is the headline result (trip cost). Below it the fuel Cost Calculator lists fuel needed and cost per mile, which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.
Checking the formula
The correct calculation divides distance by mpg to get gallons. Multiplying distance by efficiency does not give gallons and a formula that does so would give a meaningless number. A second check: 200 miles at 22 mpg is 200 ÷ 22 = 9.09 gallons, and at $2.85 a gallon that is about $25.91.
What it leaves out
- Changes in real fuel economy with speed, load, traffic and weather: the calculator assumes a constant mpg.
- Tolls, parking and wear on the vehicle.
- Splitting the cost among passengers; divide the result by the number of people.
A 300-mile trip at $3.50 a gallon by fuel economy
Every figure in this table comes from running this calculator, so it matches what the form returns.
| Fuel economy (mpg) | Trip cost | Fuel needed | Cost per mile |
|---|---|---|---|
| 20 | $52.50 | 15 gal | $0.18 |
| 25 | $42.00 | 12 gal | $0.14 |
| 30 | $35.00 | 10 gal | $0.12 |
| 40 | $26.25 | 7.5 gal | $0.09 |
What happens with invalid input
These messages are produced by the calculator itself, so you know what to fix.
- Fuel economy: entering "0" shows "Fuel economy must be greater than 0." beside that field and no result.
Choosing between the Fuel Cost Calculator and similar calculators
Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.
| Calculator | You enter | It returns |
|---|---|---|
| [Fuel Savings Calculator](/automotive/fuel-savings-calculator/) | miles driven per year, current fuel economy and new fuel economy | Annual savings |
| [MPG Calculator](/automotive/mpg-calculator/) | miles driven and gallons used | Fuel economy |
| [Distance per Tank Calculator](/automotive/distance-per-tank-calculator/) | tank size and fuel economy | Range |
| [EV Charging Cost Calculator](/automotive/electric-vehicle-charging-cost-calculator/) | usable battery capacity, starting charge and target charge | Charging cost |
| [Marginal Cost Calculator](/business/marginal-cost/) | total cost before, total cost after and quantity before | Marginal cost |
Background: vehicle sizing and speed
A taller tyre travels farther per revolution, so the speedometer reads low and the effective gear ratio becomes numerically lower; a shorter tyre does the opposite. True speed is roughly the speedometer reading times the new tyre diameter divided by the old one. Verify with GPS over a known distance before changing parts.
Assumptions and limitations
- Constant fuel economy assumed
If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for fuel economy to confirm this.
Frequently asked questions
How do I calculate gas cost for a trip?
Divide the distance by your car's miles per gallon to get gallons used, then multiply by the price per gallon.
What does the Fuel Cost Calculator calculate?
Trip fuel cost from distance, fuel economy and price. It returns Trip cost, Fuel needed and Cost per mile.
What formula does the Fuel Cost Calculator use?
cost = distance ÷ mpg × price per gallon. US gallons and miles.
What do I need to enter in the fuel Cost Calculator?
You enter Distance (miles), Fuel economy (mpg) and Fuel price ($ per gallon).
How is the result rounded or limited?
IEEE-754 double precision; shown to at most 6 decimal places. Constant fuel economy assumed.
What is an example of a fuel Cost result?
With distance 300, fuel economy 30 and fuel price 3.5, the trip cost is $35.00.
Related calculators
- Fuel Savings Calculator — Yearly fuel savings from a more efficient vehicle.
- MPG Calculator — Miles per gallon from distance and fuel used.
- Distance per Tank Calculator — Range on a full tank from tank size and fuel economy.
- EV Charging Cost Calculator — Cost of charging between two battery levels.
- Marginal Cost Calculator — Extra cost of producing additional units.
- Opportunity Cost Calculator — Value given up by choosing one option over another.
- Fuel Economy Converter — Convert mpg (US and UK), km/L and L/100 km.
Sources
- OpenStax, University Physics Volume 1 (Rice University): mechanics
Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.