Dev.to WebDev 🛠 Dev 👁 0 📖 7 min read

I Built a Free EV vs Petrol Calculator — Here's the Math That Decides If an EV Actually Saves You Money

Most EV vs petrol debates start in the wrong place: the sticker price. The EV costs more on day one, the petrol car looks cheaper, and the conversation ends there. But nobody buys a car for day one. You buy it for the ki

Most EV vs petrol debates start in the wrong place: the sticker price.
The EV costs more on day one, the petrol car looks cheaper, and the conversation ends there. But nobody buys a car for day one. You buy it for the kilometres you will drive over the next five, eight or ten years — and that is where the maths quietly flips. Or doesn't.
I built a free ev vs petrol calculator that runs exactly this comparison: cost per km, monthly fuel savings, break-even time and mileage, and 1–10 year total cost of ownership. Building it forced me to make the maths explicit, and the pattern in the numbers is consistent. The buyers who get the answer wrong are not the ones who can't do arithmetic. They are the ones who compare the wrong two numbers — purchase price against purchase price, instead of total cost against total cost.
This is the logic behind the calculator, and how to use it on your own numbers.

Break-even is a distance, not a date

Every EV vs petrol comparison has the same shape. The EV usually carries a price premium upfront. In return, every kilometre you drive costs less — cheaper energy per kilometre, and typically lower routine maintenance, because an electric drivetrain has far fewer moving parts to service than a petrol engine.
Break-even is a distance, not a date.
So the break-even point is a simple division:
break-even km = EV price premium / saving per km
That one line explains why two buyers can look at the same two cars and reach opposite conclusions. The premium is fixed on the day you buy. The saving per kilometre depends on your fuel and electricity prices, your car's efficiency, and how you charge. And the total saving depends on how many kilometres you actually drive before you sell the car.
A buyer who drives 500 km a month and a buyer who drives 2,000 km a month are not buying the same deal, even if they buy the same two cars at the same prices.
For the low-mileage driver, the premium may never be recovered.
For the high-mileage driver, the EV can pay for its premium and then keep saving money every month after that.
Time matters only because kilometres accumulate over time — so always convert a break-even time back into kilometres, and ask whether you will really drive that far in that car.
Cost per km is the number that does the work
Forget the monthly fuel bill for a moment. The number that decides the comparison is the cost of driving one kilometre:
// Petrol
const petrolCostPerKm = petrolPricePerLitre / kmPerLitre;

// EV
const evCostPerKm = electricityPricePerUnit / kmPerUnit; // km per kWh
Two things make the EV side trickier than it looks.
Your electricity price is not one number
Home charging is usually the cheapest way to run an EV; public fast charging can cost several times as much per unit. A driver who charges at home most nights and uses public chargers only on longer trips will have a very different cost per kilometre from a driver who depends on public charging every day.
That is why the calculator uses a blended rate, not a single tariff:
const blendedRate =
homeShare * homePricePerUnit +
publicShare * publicPricePerUnit;

const evCostPerKm = blendedRate / kmPerUnit;
If you are comparing, use a blend that matches your real life, not the cheapest rate on the tariff sheet. If you cannot charge at home, run the numbers with public charging rates as your main rate, not as an occasional extra. Same car, same distance, different answer.
Efficiency is not a brochure number
Real-world range and real-world mileage both fall short of laboratory figures, and they fall short by different amounts for different cars and driving styles. Use realistic figures for both sides, or the comparison is rigged before it starts.

A worked example: 1,000 km a month in India

Here is a worked example from my EV vs petrol cost calculator, for a buyer driving 1,000 km a month in India, with an EV that costs ₹5,00,000 more than the comparable petrol car:

EV
Petrol
Cost per km
₹1.73
₹6.67
Operating saving
₹59,200 per year
—
Break-even (fuel saving only)
8.45 years
—
5-year total cost of ownership
₹11,13,442
₹11,31,295
Read that carefully, because it contains the surprise most buyers miss. At five years, the EV is already ahead on total cost — by ₹17,853 — even though the operating savings alone have not yet repaid the full ₹5,00,000 premium.
That is because total cost of ownership is not just purchase price plus fuel. It includes maintenance, insurance and depreciation, and those lines move in the EV's favour too. A buyer who only divides the premium by the fuel saving will conclude the EV needs 8.45 years to win. A buyer who runs the full five-year total sees it winning sooner.
// Simplified TCO — the calculator runs this year by year, for 1–10 years
const totalCost =
purchasePrice

  • fuelOrElectricityCost
  • maintenance
  • insurance
  • resaleValue; The same example also shows the other side of the coin. Eight and a half years is a long time to wait for the fuel saving alone to repay the premium. If you change cars every four or five years, you are relying on the total-cost picture — including what the car is still worth when you sell it — not on fuel savings alone. And if you drive far less than 1,000 km a month, the yearly saving shrinks, the payback stretches, and the petrol car can stay cheaper for the whole time you own it. ##The three inputs that move break-even most If you change only three inputs, you change the answer more than anything else will: How far you drive. This is the biggest lever, and the one buyers most often guess at. Check your actual monthly distance — from service records or your odometer, not from a feeling — before you compare. A 50% error in your mileage is a 50% error in your saving. How you charge. Home charging versus public charging is often the difference between a clear EV win and a marginal one. Get the blend right. The price premium — and what you get back at resale. The premium is what has to be repaid, so a smaller gap between the EV and its petrol equivalent shortens break-even directly. Resale value cuts the other way: it is the part of the purchase price you recover, so a car that holds its value better effectively costs you less to own, whatever its sticker price said. Everything else — servicing, insurance, taxes and incentives — matters, but these three decide the shape of the answer. Get them right and the rest is fine-tuning. Get them wrong and no amount of precision elsewhere will save the comparison. ##When the EV wins — and when petrol still does Put the maths together and the pattern is clear. An EV is the stronger financial choice when you drive a lot, you can charge at home most of the time, and you will keep the car long enough for the per-kilometre saving to do its work. A high-mileage commuter with home charging is the textbook case. A petrol car still wins when the annual distance is low, when you depend on expensive public charging, when you change cars every few years, or when the EV premium over the petrol equivalent is large and the per-kilometre saving is small. None of that is an argument against EVs in general. It is an argument for doing your own numbers instead of borrowing someone else's conclusion. The practical way to decide is to run your own figures — your mileage, your fuel price, your electricity tariff and your charging mix — and to look at the five-year total cost, not just the fuel bill. If the EV wins on your numbers, buy it with confidence. If it doesn't, wait. Prices, charging and your own mileage will all move, and the answer next year may not be the answer this year. Try it with your numbers on the free ev vs petrol calculator — it covers cost per km, monthly savings, break-even and 1–10 year TCO, with INR-first pricing plus USD, GBP, AUD and EUR, km/miles support, and a home vs public charging blend. ##Key takeaways Compare total cost of ownership, not sticker price: purchase price, fuel or electricity, maintenance, insurance and resale value together. Break-even is a distance: EV price premium / saving per km. Convert any break-even time back into kilometres and ask if you will drive that far. Cost per km decides the comparison — and your charging mix (home vs public) can change it more than the car itself. In the worked example (1,000 km/month, ₹5,00,000 premium), operating savings are ₹59,200 a year, fuel-only payback is 8.45 years, but the 5-year total cost already favours the EV: ₹11,13,442 vs ₹11,31,295. Run your own numbers with your mileage, prices and charging mix before deciding.

Maniteja is the founder of evvspetrolcalculator.com, a free EV vs petrol calculator for car buyers, covering cost per km, monthly fuel savings, break-even time and total cost of ownership.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.