Hourly to Salary Conversion: The Math Behind Pay Transparency
"$25 an hour" sounds simple. It is not. The same hourly rate can mean a $52,000 salary or a $45,000 one, depending on how many hours you actually work, whether you get paid holidays, and what overtime does to the picture. As developers, we are the people asked to build the converters — and the maths behind them is full of assumptions that deserve to be explicit.
In this article, we will build a correct hourly-to-salary converter in JavaScript, including the edge cases most online calculators quietly ignore. If you just want the number, the free Hourly to Salary Calculator does it instantly — but read on if you want to understand what is happening under the hood.
The Naive Formula
The textbook conversion every developer writes first:
function hourlyToAnnual(hourlyRate, hoursPerWeek = 40) { return hourlyRate * hoursPerWeek * 52; } hourlyToAnnual(25); // 52,000 It is correct — for a very specific person: someone who works exactly 40 hours every week of the year, with no unpaid time off. That person barely exists. The moment you add reality, the formula grows.
Step 1: Account for Unpaid Time Off
Most salaried roles include paid holidays, but many hourly roles do not. Two weeks of unpaid holiday removes 80 hours from the year:
function hourlyToAnnual(hourlyRate, options = {}) { const { hoursPerWeek = 40, weeksPerYear = 52, unpaidWeeksOff = 0, } = options; const paidWeeks = weeksPerYear - unpaidWeeksOff; return hourlyRate * hoursPerWeek * paidWeeks; } hourlyToAnnual(25, { unpaidWeeksOff: 2 }); // 48,000 That is a $4,000 difference from the naive answer — the difference between an offer that looks good and one that does not. Any converter that hard-codes 52 weeks is silently overstating the salary of every hourly worker who takes unpaid leave.
Step 2: The Reverse Direction
Converting salary to hourly is not just the same formula backwards. The divisor matters: divide by the hours you actually work, not the hours in a theoretical year:
function annualToHourly(annualSalary, options = {}) { const { hoursPerWeek = 40, weeksPerYear = 52, unpaidWeeksOff = 0, } = options; const totalHours = hoursPerWeek * (weeksPerYear - unpaidWeeksOff); return annualSalary / totalHours; } annualToHourly(60000); // 28.85 annualToHourly(60000, { unpaidWeeksOff: 2 }); // 30.00 Same salary, different hourly rate — because the second person works fewer hours for the same money. This is the number that matters in a negotiation: your effective hourly rate is what your time is actually worth, and it rises when you take time off without losing pay.
Step 3: Overtime Changes Everything
In the US, non-exempt workers earn time-and-a-half beyond 40 hours a week. A converter that ignores overtime understates the pay of anyone regularly working 45 or 50 hours:
function hourlyToAnnualWithOvertime(hourlyRate, hoursPerWeek, options = {}) { const { weeksPerYear = 52, unpaidWeeksOff = 0 } = options; const paidWeeks = weeksPerYear - unpaidWeeksOff; const regularHours = Math.min(hoursPerWeek, 40); const overtimeHours = Math.max(hoursPerWeek - 40, 0); const weeklyPay = regularHours * hourlyRate + overtimeHours * hourlyRate * 1.5; return weeklyPay * paidWeeks; } hourlyToAnnualWithOvertime(25, 50); // 71,500 hourlyToAnnualWithOvertime(25, 40); // 52,000 Ten extra hours a week at time-and-a-half adds $19,500 a year to a $25/hour job. That is why "hourly vs salary" comparisons that ignore overtime are misleading — a $60,000 salary can be a pay cut for someone working 50-hour weeks at $25 an hour.
Step 4: Monthly, Weekly, and Daily Breakdowns
People rarely think in annual figures. A complete converter returns every period:
function fullBreakdown(hourlyRate, options = {}) { const annual = hourlyToAnnualWithOvertime( hourlyRate, options.hoursPerWeek ?? 40, options ); return { hourly: hourlyRate, daily: round(annual / 260), // 52 weeks × 5 days weekly: round(annual / 52), biweekly: round(annual / 26), monthly: round(annual / 12), annual: round(annual), }; } function round(value) { return Math.round((value + Number.EPSILON) * 100) / 100; } Note the 260 working days — 52 weeks of five days. If you divide the annual figure by 365, you are pricing weekends, which nobody pays for. Small constants like this are where converters quietly go wrong, so name them and comment them.
Edge Cases Worth Handling
1. Part-time and irregular hours. A 20-hour week at $30 an hour is $31,200 a year — but only if the hours are consistent. For variable schedules, accept an average weekly hours figure and say so in the UI. A converter that pretends irregular hours are regular is worse than one that admits uncertainty.
2. Contractors vs employees. A freelancer's $50 an hour is not a $104,000 salary. They pay their own taxes, get no paid leave, and fund their own benefits. A common rule of thumb is that an employee's total compensation costs roughly 1.25–1.4× their salary, so the equivalent hourly rate for a contractor is correspondingly higher. If your converter serves freelancers, say this explicitly.
3. Unpaid breaks and split shifts. Some hourly roles include unpaid meal breaks that reduce paid hours below the shift length. An 8-hour shift with a 30-minute unpaid break is 7.5 paid hours — over a year, that half-hour costs about $3,250 at $25 an hour.
4. Floating-point money. Always round to cents at the display boundary, never in the middle of a calculation chain. Math.round((value + Number.EPSILON) * 100) / 100 avoids the classic 0.1 + 0.2 problem when a value lands exactly on a half-cent.
5. Salary does not mean 2,080 hours. The 2,080-hour year (40 × 52) is a convention, not a law. Salaried workers routinely work more, which is exactly why the effective hourly rate of a salary can be lower than it looks — and why the conversion is a negotiation tool, not just a calculator.
Putting It Together
A clean API hides the options behind sensible defaults and returns a full breakdown:
const result = fullBreakdown(25, { hoursPerWeek: 45, unpaidWeeksOff: 2, }); console.log(result); // { // hourly: 25, // daily: 259.13, // weekly: 1295.63, // biweekly: 2591.25, // monthly: 5614.58, // annual: 67375 // } One function call, every period, with the assumptions visible in the options object. That is the whole point: a good converter does not just produce a number, it makes its assumptions inspectable.
Conclusion
Hourly-to-salary conversion is a transparency tool. The maths is simple — rate × hours × weeks — but the honest version accounts for unpaid time off, overtime, and the difference between paid hours and hours on the clock. Get those three right and your converter tells the truth; miss them and it flatters every offer it touches.
If you want the answer without the code, the free Hourly to Salary Calculator handles the breakdown, including overtime and unpaid leave. And if you are building your own, keep the assumptions in the open — your users will trust the number a lot more when they can see how it was made.

