Startups

SaaS Gross Margin: How to Calculate and Improve It

SaaS gross margin explained: the formula, what belongs in cost of revenue, real margins of public software firms, what is good, and how to improve yours.

By OmniAI Editorial · Nov 23, 2026 · 12 min read

SaaS gross margin is the share of revenue left after paying the direct costs of delivering your software to customers: hosting, third-party services built into the product, customer support and onboarding. If you earn $1,000,000 in revenue and spend $220,000 delivering the service, your gross margin is 78%. That 78 cents of every dollar is what's left to pay for product development, sales, marketing, administration and, eventually, profit.

Investors watch it closely because it decides how valuable each dollar of revenue is. A software company with 80% gross margins can spend heavily on growth and still become very profitable; one with 50% margins has far less room. This guide covers the gross margin formula, exactly what to include in cost of revenue, a worked example, real gross margins of public SaaS companies from their filings, what counts as good, how gross margin compares with contribution margin and other margins, and how to improve yours, including when AI features raise costs.

SaaS Gross Margin at a Glance

Formula(Revenue − cost of revenue) ÷ revenue × 100
Typical healthy range for subscription softwareRoughly 75% or higher, with strong companies around 80% or more
Main costs includedHosting and infrastructure, embedded third-party software, payment processing, support and onboarding staff
Main costs excludedResearch and development, sales and marketing, general and administrative
Why it mattersSets how much revenue can fund growth and profit; feeds into LTV, CAC payback and valuation
Biggest threatsRising cloud or AI inference costs, heavy services work, support-intensive customers

The Gross Margin Formula

The gross margin formula is the same for any business:

Gross margin (%) = (revenue − cost of revenue) ÷ revenue × 100

Gross profit is revenue minus cost of revenue (often called cost of goods sold, or COGS). Gross margin is gross profit as a percentage of revenue.

For SaaS, many companies also calculate it separately for different revenue streams:

  • Subscription gross margin: subscription revenue minus the costs of delivering the subscription.
  • Services gross margin: implementation, training and consulting revenue minus the cost of delivering those services, often low or even negative.
  • Blended gross margin: everything together, as reported in the income statement.

Investors mostly care about subscription gross margin, because it's the recurring engine of the business.

How to Calculate SaaS Gross Margin

A tall grey bar on the left, four small light blocks stepping down to the right linked by dotted ink lines, and a shorter orange bar on the right.
Revenue minus delivery costs leaves gross profit to fund everything else.

Here's how to calculate SaaS gross margin in three steps.

Step 1: Decide what goes into cost of revenue. Include costs that rise with delivering the service to customers:

Include in cost of revenueUsually exclude (operating expenses)
Cloud hosting and infrastructure for productionHosting for development, testing and staging
Third-party software and APIs embedded in the product (for example maps, email delivery, AI model APIs)Internal tools used by the team
Payment processing fees on customer paymentsSales commissions
Customer support staff and toolsMarketing and advertising
Onboarding and implementation staff (often in services cost)Product management and engineering building new features
DevOps and site reliability work spent keeping production runningGeneral and administrative costs, office rent
Amortisation of capitalised software that delivers the service (under some policies)Research and development

Customer success is a judgement call: proactive account management aimed at expansion is often treated as a sales cost, while reactive support belongs in cost of revenue. Whatever you choose, be consistent and explain it.

Step 2: Total the costs for the period (usually a month, quarter or year, matched to revenue).

Step 3: Apply the formula.

Worked example

A B2B SaaS company has $4,000,000 of annual revenue: $3,600,000 from subscriptions and $400,000 from onboarding services.

Cost of revenue itemAnnual cost
Production cloud hosting$260,000
Embedded third-party APIs$90,000
Payment processing$60,000
Support team (4 people, salaries and tools)$380,000
Share of SRE team running production$150,000
Onboarding team (services)$330,000
Total$1,270,000
  • Subscription gross margin: subscription costs are everything except onboarding = $940,000. ($3,600,000 − $940,000) ÷ $3,600,000 = 73.9%.
  • Services gross margin: ($400,000 − $330,000) ÷ $400,000 = 17.5%.
  • Blended gross margin: ($4,000,000 − $1,270,000) ÷ $4,000,000 = 68.3%.

The blended number looks weak, but the subscription business is close to healthy. The obvious levers are support efficiency and pricing onboarding to cover its cost.

What Is a Good SaaS Gross Margin?

What is a good SaaS gross margin? For pure subscription software, roughly 75% or more is healthy, and 80% or more is strong. Below about 70%, investors start asking why: heavy services, expensive infrastructure or a business model that's closer to a service company than a software company.

Here's how real public software companies compare, using GAAP figures from their most recent annual reports filed with the SEC:

CompanyFiscal year endedRevenueGross margin
AdobeNov 2025$23.77B89.3%
AtlassianJun 2026$6.57B84.8%
HubSpotDec 2025$3.13B83.8%
DatadogDec 2025$3.43B80.0%
SalesforceJan 2026$41.52B77.7%
ServiceNowDec 2025$13.28B77.5%
ZoomJan 2026$4.87B77.0%
MongoDBJan 2026$2.46B71.7%
SnowflakeJan 2026$4.68B67.2%
DigitalOceanDec 2025$0.90B59.9%
TwilioDec 2025$5.07B48.9%
ShopifyDec 2025$11.56B48.1%

Calculated from gross profit and revenue in each company's XBRL financial data on SEC EDGAR. GAAP cost of revenue includes items such as stock-based compensation and amortisation of acquired technology, so companies' "non-GAAP" gross margins are usually a few points higher.

The pattern is clear:

  • Classic application software (Adobe, Atlassian, HubSpot) sits in the 80s.
  • Data and infrastructure platforms (Snowflake, MongoDB, DigitalOcean) run lower, because they resell large amounts of compute and storage.
  • Businesses with pass-through costs (Twilio's telecom fees, Shopify's payment processing) have much lower gross margins, even though they're software companies.

So "good" depends on the model. Compare yourself with companies that have a similar cost structure.

Gross Margin vs Contribution Margin

Five bars on an ink baseline getting shorter from left to right, the first and tallest bar orange and the rest light and grey.
Each margin subtracts more costs, from gross down to net.

Gross margin vs contribution margin is a common point of confusion. Gross margin subtracts only the cost of delivering the product. Contribution margin also subtracts other variable costs tied to each sale or customer, typically sales commissions, variable marketing spend and payment fees if they aren't already in cost of revenue. It tells you what each customer contributes toward fixed costs.

MarginSubtractsAnswers
Gross marginCost of revenueHow efficiently do we deliver the product?
Contribution marginCost of revenue plus other variable costs (commissions, variable marketing)How much does each sale contribute to fixed costs?
Operating marginAll operating expenses (R&D, S&M, G&A)Is the business profitable before interest and tax?
Free cash flow marginCash costs, including capital expenditureHow much cash does the business generate?
Net marginEverything, including interest and taxWhat's left for shareholders?

Contribution margin isn't a standard reporting line, so definitions vary by company. Gross margin is defined in financial statements and is what investors compare. Free cash flow margin feeds the Rule of 40, which combines it with growth.

How Gross Margin Changes as You Scale

Gross margin is rarely fixed. It usually moves through three phases:

Early stage: low and noisy. The first customers often get hands-on onboarding, custom work and founder-led support. Infrastructure is sized for growth that hasn't arrived yet, so fixed hosting costs are spread over little revenue. Margins of 50–70% are common and not alarming, as long as you can see what will improve them.

Growth stage: rising. Fixed infrastructure costs are shared across more customers, and engineering time goes into making the product run efficiently. Self-serve onboarding and documentation replace manual setup. Support grows more slowly than the customer base. This is when most software companies climb into the high 70s or 80s.

Mature stage: stable, with pressure points. Margins flatten. New pressures appear: moving into larger enterprise customers who expect dedicated support, adding data-heavy or AI features, expanding into regions with separate infrastructure for data residency, or price competition. Each needs to be priced so it doesn't quietly erode the margin.

Two habits help at every stage:

  • Track gross margin per customer segment and plan. Averages hide segments that cost more to serve than they pay.
  • Review cost of revenue line by line each quarter. Hosting, third-party APIs and support headcount should each grow more slowly than revenue. If one grows faster, find out why before it becomes the new normal.

A board or investor will ask not only "what is your gross margin?" but "where will it be in two years, and why?". A clear answer, backed by the cost lines that will improve, matters as much as today's number.

Why Gross Margin Matters So Much

  • It caps profitability. A company can't have an operating margin higher than its gross margin. At 50% gross margin, the best possible operating margin is below 50%.
  • It scales lifetime value. Customer lifetime value is usually calculated on gross profit, not revenue. At the same revenue per customer, a company with 80% margins earns 60% more gross profit per customer than one at 50%.
  • It sets CAC payback. Months to recover acquisition cost = CAC ÷ (monthly revenue per customer × gross margin). Lower margins mean slower payback.
  • It drives valuation. Investors pay higher revenue multiples for high-margin revenue, because more of it can become profit.

Our guide to SaaS metrics shows how gross margin feeds into these other metrics.

AI Features and Gross Margin

AI features add a new variable cost: model inference. Every chat reply, summary or generated image costs money from a model provider or for GPUs you run. Unlike traditional hosting, the cost rises directly with usage.

A worked example: a product charges $30 per user per month. A new AI assistant costs an average of $0.01 per request, and an active user makes 20 requests a day, about 600 a month. That's $6 per user per month, or 20% of the price, on top of existing delivery costs. If the product had an 80% gross margin before, it now sits closer to 60% for heavy users.

Ways teams keep AI margins healthy:

  • Price for usage: credits, usage tiers or AI add-ons. Our guide to the AI pricing model covers the options.
  • Route requests to the cheapest model that does the job well.
  • Cache repeated prompts and answers.
  • Set limits on free and low-tier plans.
  • Track gross margin by feature and plan, not just company-wide.

How to Improve SaaS Gross Margin

  1. Optimise cloud spend. Right-size instances, use reserved capacity or savings plans for steady workloads, delete idle resources and archive cold data.
  2. Fix the architecture where it counts. Inefficient queries, chatty services and missing caching often drive the biggest hosting bills.
  3. Reduce support load. Better onboarding, in-app help, documentation and fixing the top causes of tickets cut support cost per customer.
  4. Charge for services properly, or productise onboarding so it needs less human time.
  5. Raise prices or repackage when the value delivered has grown.
  6. Renegotiate third-party costs as volume grows; embedded APIs often have volume discounts.
  7. Watch the customer mix. Very small customers on cheap plans can cost more to support than they pay.

Common Mistakes

  • Leaving support out of cost of revenue to make margins look better. Investors will move it back.
  • Mixing services into subscription margin without showing them separately.
  • Ignoring free users. Free-tier hosting and AI costs are real delivery costs.
  • Comparing with the wrong peers. An infrastructure or payments business shouldn't benchmark against pure application software.
  • Not tracking by product line. A company-wide number can hide one feature or plan that loses money.

FAQ

Is gross margin the same as gross profit?

No. Gross profit is a dollar amount: revenue minus cost of revenue. Gross margin is that amount as a percentage of revenue.

Should salaries be in SaaS cost of revenue?

Salaries of people who deliver and support the service, such as support, onboarding and production operations staff, belong in cost of revenue. Salaries for building new features, sales and administration don't.

Why do investors care more about subscription gross margin?

Subscription revenue is recurring and scalable, while services revenue usually has low margins and doesn't scale as well. Subscription gross margin shows the quality of the core business.

Do early-stage startups need high gross margins?

Early startups often have lower margins because of manual work and unoptimised infrastructure. Investors look for a credible path to 75% or more as the company scales.

How often should I calculate gross margin?

Monthly for internal tracking, with quarterly and annual figures for boards and investors. Watch the trend as you add customers and features.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog