Skip to content HtmlpressStatic site generator HtmlpressStatic site generator

Change theme

Keyboard shortcuts

Electric or petrol? The carbon calculator

Updated

A what-if calculator in one HTML page. An electric car is only as clean as the grid that charges it, so pick a country, say how far and how efficiently you drive, and compare a year of CO₂ from each car. Drag the grid slider to imagine a cleaner or dirtier grid, or click any column in the chart to borrow another country's. Every input lands in the address bar, so a copied link reopens the exact scenario.

Calculator

Every grid, same car Electric car, g CO₂ per km · click a column to use that grid

What it shows

With the default car, the electric one wins on every grid in the chart, even Kazakhstan's, which burns coal for most of its power. The gap is what changes: charged in Norway or France the electric car emits a few percent of the petrol one; charged in South Africa or India, about three-quarters. Shrink the petrol car to a frugal hybrid's 4 litres and the dirtiest grids start to lose, which is why the break-even line under the verdict is the number worth remembering.

The comparison counts driving only, not building the cars: making a battery adds emissions up front that the electric car pays back over its first years. The grid figures are lifecycle averages, while the petrol figure counts only what leaves the exhaust, not refining and shipping the fuel, so the petrol car is, if anything, flattered.

How it's built

  • Three lines of arithmetic. Electric g/km is grid g/kWh × kWh/100 km ÷ 100; petrol g/km is L/100 km × 2,348 g ÷ 100; the break-even grid is the petrol g/km divided by the electric car's kWh per km. Everything else on the page is presentation.
  • The inputs are native: a <select> and four <input type="range">, so keyboard, screen reader and touch support come with them. Picking a country resets the grid slider; dragging it away shows a link back.
  • The scenario is the address. Every change rewrites the hash, and the share button copies location.href with the Clipboard API.

Sources: carbon intensity of electricity generation, latest year (2025, or 2024 for Iceland, Indonesia and Saudi Arabia), from Ember and the Energy Institute, as compiled by Our World in Data; 8,887 g of CO₂ per gallon of petrol burned, from the US Environmental Protection Agency. The default consumptions are typical values for a mid-size car, not data: change them to match yours.

Created with ❤ and Htmlpress

Actions

Edit on GitHubView as Markdown

Contents