Build

SaaS Gross Margin: Formula and Cost-of-Revenue Decisions

Calculate gross profit and margin, then document the cost classifications that make the result meaningful.

Published
Read time4 min read
Minimal editorial illustration of revenue, direct service costs, and gross profit connected through a structured calculation.

SaaS gross margin measures the share of recognized revenue left after subtracting the costs you classify as cost of revenue. The standard formula is (Revenue − Cost of Revenue) ÷ Revenue × 100. The arithmetic is straightforward; deciding which costs belong in cost of revenue is the judgment-heavy part.

A SaaS company should document its cost classification and apply it consistently. Hosting, support, and software delivery costs are common candidates, but no single list fits every product or accounting policy. Stripe’s SaaS gross margin guide describes common categories and explains why the distinction from operating expenses matters.

Gross margin formula: define each variable#

Use the following formula for a defined reporting period and revenue scope:

Gross margin (%) = ((R − C) ÷ R) × 100

Where:

  • R = revenue recognized for the period and business segment being measured.
  • C = costs classified as cost of revenue for that same period and segment.
  • R − C = gross profit, expressed in the same currency as revenue.

For example, if a product has $80,000 in revenue and $24,000 in cost of revenue for a month, gross profit is $80,000 − $24,000 = $56,000. Gross margin is $56,000 ÷ $80,000 × 100 = 70%. These are illustrative inputs, not a benchmark or expected SaaS result.

Gross profit, gross margin, and net profit are different#

Revenue is the amount recognized for the period. Gross profit is revenue minus the cost of revenue. Gross margin is gross profit divided by revenue, expressed as a percentage. Net profit is calculated after subtracting all applicable expenses and other items under the company’s accounting basis; it is not the same as gross profit.

A product can show a positive gross margin and still lose money after research and development, sales and marketing, general and administrative expenses, interest, taxes, or other items. Gross margin alone does not establish whether a company is profitable.

Which SaaS costs belong in cost of revenue?#

Classify costs based on their relationship to delivering the service, the company’s accounting policy, and the metric being reported. Keep the rationale documented so comparisons across periods and products remain meaningful.

Cost categoryPossible treatmentClassification question
Hosting, compute, storage, bandwidthOften cost of revenue when directly used to deliver the serviceCan the cost be linked to running the customer-facing service, and how is shared infrastructure allocated?
Customer supportMay be cost of revenueIs the team primarily delivering contracted support, or is it a broader customer-success function?
Engineering and maintenancePolicy-dependentIs the work maintaining the current service, developing new products, or shared across both?
Payment processingOften treated as a direct delivery or transaction cost in internal models; financial-statement presentation can differAre processor fees included consistently in the chosen gross-margin definition?
Sales and marketingUsually an operating expense rather than cost of revenueDoes the expense directly deliver the contracted service, or acquire demand?
General and administrativeUsually an operating expenseIs the cost corporate overhead rather than service delivery?

These are practical questions, not universal accounting rulings. For example, Stripe’s overview lists hosting and infrastructure, customer support, and some development and maintenance costs among common SaaS cost-of-revenue categories, while noting that treatment varies and that non-GAAP measures can exclude items such as stock-based compensation. A company’s formal financial reporting should follow the applicable accounting framework and its own policies.

Calculate gross margin with a consistent example#

Assume a hypothetical SaaS product reports $80,000 of revenue in one month. For this management model, the company classifies $14,000 of hosting and infrastructure, $6,000 of customer support, and $4,000 of payment processing as cost of revenue. It treats engineering for new features, marketing, and general administration as operating expenses outside this gross-margin calculation.

InputAmountTreatment in this example
Recognized revenue$80,000Revenue for the month
Hosting and infrastructure$14,000Cost of revenue
Customer support$6,000Cost of revenue
Payment processing$4,000Cost of revenue
Total cost of revenue$24,000$14,000 + $6,000 + $4,000
Gross profit$56,000$80,000 − $24,000
Gross margin70%$56,000 ÷ $80,000 × 100

The arithmetic is: gross profit = $80,000 − ($14,000 + $6,000 + $4,000) = $56,000. Gross margin = $56,000 ÷ $80,000 × 100 = 70%. This result is valid only for the stated revenue and cost classification.

Gross margin versus contribution margin#

Gross margin uses the costs classified as cost of revenue. Contribution margin typically subtracts the variable costs relevant to a particular decision from revenue. The two measures can be close, but they are not interchangeable unless the underlying cost definitions match.

For example, a pricing model might subtract payment processing and usage-based API costs to estimate contribution per customer even if the company’s reported gross-margin calculation allocates some of those costs differently. State which costs are included before comparing the metrics.

How to use the SaaS Pricing Calculator#

Use the SaaS Pricing Calculator to model your own pricing and cost assumptions. Its indexed description lists fixed costs, variable costs, payment-fee inputs, revenue, gross profit, gross margin, net profit after fixed costs, and break-even customers. It supports flat, per-seat, and usage-based pricing.

Treat the calculator’s outputs as a scenario model, not as a substitute for your accounting records. The indexed tool description says it assumes steady-state average usage and excludes churn, taxes and VAT, refunds, free plans and trials, sales commissions, and revenue-recognition timing. It also does not perform currency conversion. Confirm the current live interface and its inputs before relying on a particular output.

Common gross-margin mistakes#

  • Mixing periods: divide gross profit by revenue from the same period and scope.
  • Changing classifications between periods without explaining the change: trends can become misleading even when the arithmetic is correct.
  • Treating all engineering expense alike: maintenance, service delivery, and new-product development may need different treatment under the company’s policy.
  • Comparing unlike metrics: GAAP/IFRS financial reporting, adjusted non-GAAP measures, and internal contribution models may exclude different costs.
  • Calling gross margin profitability: operating expenses and other items still affect net profit.
  • Using an industry benchmark as a target without matching business model, product mix, accounting policy, and cost definitions.

References#

Muhammad Azlaan Zubair

Software Engineer and Researcher, writing about AI, developer tooling and automation.

Newsletter

New guides, comparisons and analysis, sent only when there is something worth your time.

  • New articles worth your time, not every link we publish.
  • Tools and resources when they launch.
  • No spam, no selling your address. Unsubscribe anytime.

Get useful signal by email

We're building the list before the first issue. You'll get an email when the newsletter starts.