DEV Community

Cover image for How I built a fast Freelance Rate Calculator in Vanilla JS
NovusTools
NovusTools

Posted on • Originally published at novustools.com

How I built a fast Freelance Rate Calculator in Vanilla JS

As developers and designers, transitioning to freelance work means figuring out exactly how much to charge to hit our financial goals. I got tired of doing the math manually every time my expenses changed, so I built a clean, client-side Freelance Rate Calculator.

The Approach

I built this using 100% Vanilla JS. Financial goals and business expenses are highly private, so I made sure there are zero server calls. Everything calculates instantly in the browser.

Here is a quick look at the core logic for calculating the required hourly rate:

function calculateHourlyRate(targetAnnualIncome, annualExpenses, billableHoursPerWeek, weeksWorkedPerYear) {
    const totalRequiredRevenue = targetAnnualIncome + annualExpenses;
    const totalBillableHours = billableHoursPerWeek * weeksWorkedPerYear;

    const hourlyRate = totalRequiredRevenue / totalBillableHours;

    return {
        hourlyRate: hourlyRate.toFixed(2),
        minimumDailyRate: (hourlyRate * 8).toFixed(2)
    };
}
Enter fullscreen mode Exit fullscreen mode

Try it out

You can use the live tool for free here: Freelance Rate Calculator

Let me know what you think or if you'd add any other variables to the calculation in the comments!

Top comments (0)