Amazon (NASDAQ:AMZN) and Shopify (NYSE:SHOP) are perhaps two of the best ways to profit from the surging global growth of e-commerce. The online shopping king and digital commerce software maker are up an incredible 280% and 350%, respectively, over the last three years -- and both appear poised for much more gains ahead.

But which is the better buy today? Read on to find out.

Rising stacks of blocks with the word e-commerce and an upwardly sloping arrow above them

We pit Amazon and Shopify against each other to see which of these e-commerce winners is the best choice for your portfolio. Image source: Getty Images.

Moat

Of all the businesses I cover, not one has more powerful competitive advantages than Amazon. The e-commerce juggernaut dominates online shopping here in the U.S. and, increasingly, many other areas of the world. Its Amazon Web Services division controls more than 60% of the public cloud market -- an industry that will grow to more than $400 billion by 2020, according to Gartner. Amazon is also a titan in streaming video, groceries (thanks to its acquisition of Whole Foods), smart-home devices, digital advertising, and a steadily growing list of other products and services.

And yet, Amazon was bested by a tiny upstart in one important area: e-commerce tools for small businesses. That is an area dominated by Shopify, particularly since Amazon closed its competing service in 2015 and ceded the market to its smaller rival. Since that time, Shopify's merchant base has ballooned to more than 600,000 businesses that have collectively sold over $55 billion worth of goods on its platform. The company has become a vital partner to entrepreneurs across the world by supplying the tools necessary for them to compete in an increasingly digital world.

All told, Amazon and Shopify both enjoy powerful competitive advantages, but based on its dominant position within multiple important industries, I'd argue Amazon has the wider economic moat.

Advantage: Amazon

Financial fortitude

Amazon is obviously the far larger and more financially powerful business, but it's important to review some key financial metrics to inform our analysis.

Metric

Amazon

Shopify

Revenue

$177.87 billion

$673 million

Operating income

$4.11 billion

$49 million

Net income

$3.03 billion

($40 million)

Operating cash flow

$18.43 billion

$8 million

Free cash flow

$6.48 billion

($16 million)

Cash

$30.99 billion

$943 million

Debt

$44.15 billion

N/A

Data sources: Morningstar, Yahoo! Finance.

Amazon is notorious for generating low net income and free cash flow relative to its massive revenue base, but that's largely a function of its heavy growth investments. Shopify is in a similar position in that it's spending heavily in order to capture a larger share of its immense market opportunity. However, Amazon still produced more than $3 billion in net income and $6 billion in free cash flow over the past year. Meanwhile, Shopify's spending continues to generate losses and negative free cash flow. Helping to offset this somewhat is Shopify's pristine balance sheet, which contains nearly a billion dollars in cash and no debt. So Shopify should be able to continue to fund its impressive growth for the foreseeable future. Amazon, though, clearly has the edge in terms of financial strength.

Advantage: Amazon

Growth

Amazon may be more financially powerful, but Shopify is growing much faster.

SHOP Revenue (TTM) Chart

SHOP Revenue (TTM) data by YCharts.

Wall Street expects this trend to continue. Analysts forecast that Amazon's revenue will increase by 31% in 2018 and 22% in 2019, driven by the relentless expansion of its e-commerce operations, the surging growth of Amazon Web Services, and gains related to its acquisition of Whole Foods.

However, Shopify's revenue is projected to surge by an even more impressive 48% in 2018 and 37% in 2019, fueled by its mobile commerce initiatives, international expansion, and new partnerships.

For a business of Amazon's immense size -- its market cap currently checks in at $680 billion -- these growth rates are extraordinary. But with its significantly higher expected sales growth in the coming years, Shopify has the edge here.

Advantage: Shopify

Valuation

No better-buy discussion should take place without a look at valuation. Let's check out some key value metrics for Amazon and Shopify, including price-to-sales, price-to-cash flow, and price-to-earnings ratios.

Metric

Amazon

Shopify

P/S

3.82

18.37

P/OCF

36.91

1,565.82

P/FCF

104.98

N/A

Trailing P/E

228.49

N/A

Forward P/E

91.31

234.84

Data sources: Morningstar, Yahoo! Finance.

Amazon's and Shopify's valuations are not for the faint of heart. These are not cheap stocks, at least not by any traditional valuation metric. Even if we attempt to adjust for their heavy growth investments, Amazon and Shopify are still richly valued. Still, as its shares are less expensive than Shopify's on most of the above metrics, I'll say Amazon is the better deal. 

Advantage: Amazon 

The better buy is...

Amazon and Shopify are both outstanding businesses that are likely to continue to deliver solid long-term gains to investors. But with its wider moat, superior financial strength, and more attractively priced stock, Amazon is the better buy today.