
Electricity cost calculator
Estimate energy use and cost from entered power, usage time and rate.
Your inputs stay in your browser.
Method and assumptions
Method version 1.0.0 · Updated
Calculate cost
Formula: Energy (kWh) = power (W) × hours × days ÷ 1,000.
The monetary result uses the currency of your rate.
- powerWatts
- Power (W)
- hoursPerDay
- Hours used per day
- days
- Number of days
- pricePerKwh
- Price per kWh
Power is assumed constant throughout the usage period. The entered rate is applied to all energy; standing charges, taxes and time-of-use pricing are excluded.
Calculate with code
These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.
JavaScript
const watts = 1000, hoursPerDay = 3, days = 30, pricePerKwh = 0.25;
const kwh = watts * hoursPerDay * days / 1000;
console.log(kwh, kwh * pricePerKwh); // 90 kWh, 22.50TypeScript
const watts = 1000, hoursPerDay = 3, days = 30, pricePerKwh = 0.25;
const kwh = watts * hoursPerDay * days / 1000;
console.log(kwh, kwh * pricePerKwh); // 90 kWh, 22.50Python
kwh = 1000 * 3 * 30 / 1000
print(kwh, kwh * 0.25) # 90.0 kWh, 22.5Java
double kwh = 1000 * 3 * 30 / 1000.0;
System.out.println(kwh + " kWh, cost=" + kwh * 0.25); // 90.0, 22.5C#
decimal kwh = 1000m * 3 * 30 / 1000;
Console.WriteLine($"{kwh} kWh, cost={kwh * 0.25m}"); // 90, 22.50