Over the past two decades, a growing number of companies have replaced their on-premise software with cloud-based subscription services. Those software-as-a-service (SaaS) solutions enable software companies to generate stable recurring revenues from their clients instead of relying on periodic upgrades. They also benefit customers with growing businesses since it's easier to scale those services across a large number of devices.

Salesforce (CRM 1.27%) and ServiceNow (NOW 1.13%) have both profited from that secular trend. Salesforce, which was founded in 1999, is the world's largest provider of cloud-based customer relationship management (CRM) services. ServiceNow, founded in 2003, optimizes an organization's digital workflows with its cloud-based tools.

A person accesses cloud-based apps on a tablet computer.

Image source: Getty Images.

Over the past five years, Salesforce's stock has rallied more than 130% -- but ServiceNow delivered a much bigger gain of nearly 500%. Let's see why ServiceNow outperformed Salesforce and whether or not it will maintain that momentum and remain the stronger SaaS stock.

Which company is growing faster?

Between fiscal 2017 and fiscal 2022 (which ended this January), Salesforce's annual revenue increased at a compound annual growth rate (CAGR) of 25.9% to $26.5 billion. Those robust returns were driven by the organic growth of its core CRM business and the inorganic expansion of its sales, marketing, e-commerce, and analytics cloud services.

Salesforce expects its annual revenue to surpass $50 billion in fiscal 2026, which would represent a CAGR of at least 17.4% over the next four years. It expects the stable growth of the CRM market and the expansion of its adjacent cloud services -- which will serve the ongoing digitization of a wide range of industries -- to propel it toward that target.

ServiceNow's annual revenue grew at a CAGR of 33.1% to $5.8 billion between fiscal 2016 and fiscal 2021 (which aligns with the calendar year). It significantly expanded its ecosystem with over a dozen acquisitions during that period and benefited from the growing demand for digital workflow services as companies relied more heavily on remote and hybrid workers.

The company expects to generate more than $15 billion in annual revenue in 2026 -- which would represent a CAGR of at least 20.9% over the next five years. During its last conference call, CEO Bill McDermott said the company's "organic growth machine is in full flight" and wouldn't need to rely on further mergers and acquisitions (M&A) for its future growth.

Which company is more profitable?

In addition to similar top-line growth, both companies generate comparable gross margins. Salesforce ended fiscal 2022 with a gross margin of 73%, which slipped from 74% a year earlier. ServiceNow's gross margin also dipped by a percentage point to 77% in 2021.

Unlike many other smaller SaaS companies, Salesforce and ServiceNow are profitable by both generally accepted accounting principles (GAAP) and non-GAAP measures. However, ServiceNow has consistently generated stronger non-GAAP earnings growth than Salesforce.

Over the past five fiscal years, Salesforce grew its non-GAAP earnings per share (EPS) at a CAGR of 36.5%, but ServiceNow's non-GAAP EPS increased at a much higher CAGR of 53.3%. Analysts expect that trend to continue.

Non-GAAP EPS Growth (Estimated)

Current Fiscal Year

Next Fiscal Year

Salesforce

(2.7%)

24.1%

ServiceNow

24.3%

26.7%

Data source: Yahoo Finance, April 8. Chart by author.

Salesforce's earnings are expected to dip this year as it integrates its latest acquisitions and faces tougher currency- and tax-related headwinds. ServiceNow doesn't need to deal with any near-term acquisition-related costs, and it doesn't face as many currency or tax-related challenges.

But one of these SaaS stocks is a lot pricier

If we only look at their revenues, margins, and earnings, ServiceNow looks like a slightly better investment than Salesforce.

However, ServiceNow's stock also trades at 79 times forward earnings and 14 times this year's sales. Salesforce trades at 47 times forward earnings and just six times this year's sales. That's a low price-to-sales ratio for a company that aims to nearly double its annual revenues over the next five years. For reference, Adobe -- another SaaS peer growing at a slower rate than Salesforce -- trades at 12 times this year's sales.

The winner: Salesforce

I like both of these SaaS stocks, but rising interest rates and other macroeconomic headwinds will likely make pricier stocks like ServiceNow less appealing than more reasonably valued ones like Salesforce. Therefore, I think investors can safely buy some shares of Salesforce today, but they should wait for ServiceNow to cool off before pulling the trigger.