Skip to content
CalculatorAtlas

Fuel Cost Calculator

Tested

Trip fuel cost.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

miles
mpg
$ per gallon

Results

Enter your values and press Calculate. Results appear here.

  • • Result

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

  1. Enter distance (miles) (above 0).
  2. Enter fuel economy (mpg) (above 0).
  3. Enter fuel price ($ per gallon) (0 or more).
  4. Press Calculate to see the result, and use Reset to start again.
Inputs of the Fuel Cost Calculator
InputWhat to enterAllowed values
DistanceA number, in miles> 0
Fuel economyA number, in mpg> 0
Fuel priceA 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.

Results of example 1
ResultValue
Trip cost$35.00
Fuel needed10 gal
Cost per mile$0.12

Example 2

Inputs: Distance = 120; Fuel economy = 25; Fuel price = 4.

Results of example 2
ResultValue
Trip cost$19.20
Fuel needed4.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.

A 300-mile trip at $3.50 a gallon by fuel economy
Fuel economy (mpg)Trip costFuel neededCost per mile
20$52.5015 gal$0.18
25$42.0012 gal$0.14
30$35.0010 gal$0.12
40$26.257.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.

Choosing between the Fuel Cost Calculator and similar calculators
CalculatorYou enterIt returns
[Fuel Savings Calculator](/automotive/fuel-savings-calculator/)miles driven per year, current fuel economy and new fuel economyAnnual savings
[MPG Calculator](/automotive/mpg-calculator/)miles driven and gallons usedFuel economy
[Distance per Tank Calculator](/automotive/distance-per-tank-calculator/)tank size and fuel economyRange
[EV Charging Cost Calculator](/automotive/electric-vehicle-charging-cost-calculator/)usable battery capacity, starting charge and target chargeCharging cost
[Marginal Cost Calculator](/business/marginal-cost/)total cost before, total cost after and quantity beforeMarginal 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.

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.