npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@frontierhsa/canada-hsa-calculator

v1.0.0

Published

Canadian Health Spending Account (HSA) tax savings calculator with 2025 federal and provincial tax brackets

Readme

Canada HSA Calculator

A TypeScript library for calculating tax savings from a Health Spending Account (HSA) for Canadian small businesses. Includes 2025 federal and provincial tax brackets for all provinces.

Try the live calculator at Frontier HSA

What is an HSA?

A Health Spending Account (also called a Health Care Spending Account or HCSA) lets Canadian incorporated businesses pay for medical expenses with pre-tax corporate dollars instead of after-tax personal income. This can save 25-50% depending on your province and income level.

Install

npm install @frontierhsa/canada-hsa-calculator

CLI

# Install globally
npm install -g @frontierhsa/canada-hsa-calculator

# Calculate savings: hsa-calc <income> <expenses> <province>
hsa-calc 100000 3000 ON

#   Canadian HSA Tax Savings Calculator
#   ===================================
#
#   Province:           Ontario (ON)
#   Annual Income:      $100,000.00
#   Medical Expenses:   $3,000.00
#
#   Tax Rates
#   ---------
#   Federal marginal:   20.50%
#   Provincial marginal:  9.15%
#   Combined marginal:  29.65%
#
#   Comparison
#   ----------
#   Without HSA:        $4,264.39 pre-tax income needed
#   With HSA:           $3,360.00 total business cost
#
#   SAVINGS:            $904.39/year

# Custom admin fee and plan fee
hsa-calc 85000 5000 BC --admin-fee 5 --plan-fee 450

# JSON output for scripting
hsa-calc 120000 2000 AB --json

Usage

import { calculate } from "@frontierhsa/canada-hsa-calculator";

const result = calculate({
  annualIncome: 100000,
  annualMedicalExpenses: 3000,
  province: "ON",
  adminFeeRate: 0.08,   // 8% admin fee
  annualPlanFee: 120,    // $120/year platform fee
});

console.log(result.savings);            // 905.32 — yearly tax savings
console.log(result.marginalTaxRate);    // 0.2965 — combined marginal rate
console.log(result.totalBusinessCost);  // 3360   — total HSA cost
console.log(result.breakEven);          // 284.62 — min expenses to save money

API

calculate(input)

Main function. Returns tax savings from running medical expenses through an HSA vs. paying out of pocket.

Input:

| Field | Type | Description | |---|---|---| | annualIncome | number | Annual pre-tax income | | annualMedicalExpenses | number | Annual medical expenses | | province | ProvinceCode | Province code ("ON", "BC", "AB", etc.) | | adminFeeRate | number | Admin fee rate as decimal (e.g., 0.08 = 8%) | | annualPlanFee | number | Annual platform fee in dollars |

Output (CalculatorResult):

| Field | Type | Description | |---|---|---| | savings | number | Total yearly tax savings | | marginalTaxRate | number | Combined federal + provincial marginal rate | | federalTaxRate | number | Federal marginal rate | | provincialTaxRate | number | Provincial marginal rate | | adminFee | number | Admin fee amount | | totalBusinessCost | number | Total cost through HSA | | requiredPersonalIncome | number | Pre-tax income needed without HSA | | annualPlanFee | number | Annual plan fee | | breakEven | number | Minimum expenses for HSA to save money |

Tax Rate Functions

import {
  marginalFederalTaxRate,
  marginalProvincialTaxRate,
  effectiveFederalTaxRate,
  effectiveProvincialTaxRate,
  PROVINCES,
} from "@frontierhsa/canada-hsa-calculator";

// Marginal rates (rate on the next dollar earned)
marginalFederalTaxRate(100000);                    // 0.205
marginalProvincialTaxRate(100000, PROVINCES.ON);   // 0.0915

// Effective rates (average rate across all income)
effectiveFederalTaxRate(100000);                    // 0.1734
effectiveProvincialTaxRate(100000, PROVINCES.ON);   // 0.0698

Tax Bracket Data

import { FEDERAL_TAX_BRACKETS, PROVINCES } from "@frontierhsa/canada-hsa-calculator";

// 2025 federal brackets
console.log(FEDERAL_TAX_BRACKETS);
// [
//   { threshold: 57375, rate: 0.15 },
//   { threshold: 114750, rate: 0.205 },
//   { threshold: 177882, rate: 0.26 },
//   { threshold: 253414, rate: 0.29 },
//   { threshold: Infinity, rate: 0.33 },
// ]

// All provinces
Object.keys(PROVINCES); // ["AB", "BC", "MB", "NB", "NL", "NS", "ON", "PE", "SK", "YT"]

Supported Provinces

| Code | Province | |---|---| | AB | Alberta | | BC | British Columbia | | MB | Manitoba | | NB | New Brunswick | | NL | Newfoundland and Labrador | | NS | Nova Scotia | | ON | Ontario | | PE | Prince Edward Island | | SK | Saskatchewan | | YT | Yukon |

How the Math Works

  1. Marginal tax rate = federal marginal rate + provincial marginal rate for your income bracket
  2. Without HSA: You need expenses / (1 - marginalTaxRate) in pre-tax income to cover medical costs
  3. With HSA: You pay expenses + adminFee + planFee as a deductible business expense
  4. Savings = what you'd need without HSA - what you pay with HSA

Example: $3,000 in medical expenses at a 29.65% marginal rate

  • Without HSA: need $4,265 pre-tax income
  • With HSA: pay $3,360 (expenses + 8% admin + $120 fee)
  • Savings: $905/year

Development

npm install
npm test
npm run build

License

MIT - Frontier HSA