SaaS Gross Margin Formula: How to Calculate It
The SaaS gross margin formula is (revenue minus cost of revenue) divided by revenue, expressed as a percentage. Cost of revenue covers only what it takes to deliver the service: hosting, third-party software, support and onboarding staff. It excludes sales, marketing, research and development, and general overhead.
- Gross margin = (Revenue − Cost of revenue) ÷ Revenue, shown as a percentage.
- Cost of revenue is delivery cost only: hosting, product software licenses, support and onboarding staff.
- Exclude sales and marketing, R&D and G&A from cost of revenue, or the margin is understated.
- A $100,000 revenue month with $20,000 cost of revenue gives 80% gross margin.
- Track margin monthly by segment, because hosting, support and third-party fees rarely scale in a straight line.
What is the SaaS gross margin formula?
It measures the share of revenue left after delivery costs, before sales, marketing, R&D and admin. The formula is gross profit divided by revenue, where gross profit is revenue minus cost of revenue. A higher margin means each dollar of revenue costs less to deliver.
What belongs in cost of revenue for a SaaS business?
Cost of revenue includes every cost that rises when you deliver the product to a customer and would disappear if that customer left. Common items: cloud hosting, third-party software licenses embedded in the product, customer support staff, onboarding and implementation staff, and payment processing fees. It does not include rent, finance staff, sales commissions or engineering salaries.
| Include in cost of revenue | Exclude from cost of revenue |
|---|---|
| Cloud hosting and infrastructure | Sales and marketing spend |
| Third-party software embedded in the product | R&D and engineering salaries |
| Customer support staff | General and administrative costs |
| Onboarding and implementation staff | Office rent and utilities |
| Payment processing fees | Sales commissions |
The table is a common starting point, not a rule. The key test: if the cost stops when the customer leaves, it is usually delivery cost. If the cost supports the whole business, it is an operating expense.
Write your cost-of-revenue definition down once and reuse it every month. Consistency matters more than which specific line items you include.
How do you calculate SaaS gross margin step by step?
Start with total revenue for the period, subtract cost of revenue, divide the result by revenue, and multiply by 100 to get a percentage. Use the same period and the same definition each time.
-
Total revenue for the period.
-
List every cost of revenue item for the same period.
-
Sum the cost of revenue items.
-
Subtract cost of revenue from revenue to get gross profit.
-
Divide gross profit by revenue and multiply by 100.
The result is your gross margin percentage. Run the same five steps for each product line or customer segment if you want a clearer picture.
What does a worked example look like?
Assume a company reports $250,000 in monthly revenue and $55,000 in cost of revenue. Gross profit is $195,000, so gross margin is 195,000 ÷ 250,000 = 78%. That 78% is the share of each revenue dollar left to fund sales, marketing, R&D and profit.
| Line item | Amount |
|---|---|
| Total revenue | $250,000 |
| Cloud hosting | $22,000 |
| Third-party software licenses | $11,000 |
| Customer support staff | $14,000 |
| Onboarding staff | $8,000 |
| Total cost of revenue | $55,000 |
| Gross profit | $195,000 |
| Gross margin | 78% |
These numbers are an illustration only, not a benchmark. Change the inputs to match your own books. A gross margin calculator runs the same formula in seconds.
What are the most common mistakes?
The biggest mistake is mixing operating expenses into cost of revenue, which understates margin. The second is leaving out third-party software embedded in the product. The third is calculating margin once a year instead of monthly.
Other frequent errors:
- Counting all engineering salaries as delivery cost when most work is R&D.
- Ignoring payment processing fees, which scale with revenue.
- Comparing your margin to another company using a different definition.
- Forgetting that onboarding costs can be front-loaded and spike margin in the first month.
Fix the definition first, then the numbers follow. Document it in your finance and IT handover notes so the next person uses the same method.
How does gross margin connect to other SaaS metrics?
Gross margin feeds almost every downstream metric, including LTV, CAC payback and the Rule of 40. LTV uses gross margin to keep lifetime value in profit terms. CAC payback uses gross margin to show how long revenue takes to cover acquisition cost.
- LTV:CAC ratio guide: shows why LTV should be margin-adjusted.
- CAC payback calculator: uses gross profit, not revenue, in the payback period.
- Rule of 40 calculator: pairs growth with profitability, where margin matters.
- SaaS metrics library: defines the full set of formulas.
A margin figure on its own tells you little. Pair it with growth, retention and acquisition cost to see the whole picture.
How do you act on your gross margin number?
Use the margin to find which costs are eating delivery profit, then set a target and review it each month. If margin is falling, split cost of revenue into its parts and look for the line growing faster than revenue. Hosting and third-party software are the usual suspects.
For SaaS buyers, this matters too. If you resell or embed SaaS tools, your own gross margin depends on what you pay per seat. A SaaS spend and license inventory helps you see unused licenses that quietly raise cost of revenue.
Practical steps:
-
Set a target margin and review it monthly.
-
Break cost of revenue into hosting, software, support and onboarding.
-
Flag any line growing faster than revenue.
-
Renegotiate or remove unused third-party licenses.
-
Recalculate margin by segment, not just company-wide.
Do this consistently and the gross margin formula becomes a decision tool, not just a reporting line.
Frequently asked questions
What is the SaaS gross margin formula?
Gross margin = (revenue − cost of revenue) ÷ revenue × 100. Cost of revenue includes hosting, embedded software, support and onboarding staff.
What counts as cost of revenue for SaaS?
Any cost that rises with delivery to a customer: cloud hosting, third-party licenses, support and onboarding staff, and payment fees. Sales, R&D and admin costs are excluded.
What is a good gross margin for a SaaS company?
There is no universal number. Higher is generally better, and the useful comparison is your own margin over time and against peers using the same definition.
Does gross margin include sales and marketing?
No. Sales and marketing are operating expenses, not cost of revenue. Including them understates the margin and breaks comparisons.
How is gross margin different from contribution margin?
Gross margin subtracts delivery costs only. Contribution margin subtracts delivery costs plus variable selling costs, so it is usually lower.