Amazon.com (NASDAQ:AMZN) and Walmart (NYSE:WMT) together generate nearly $700 billion in annual revenue. They produce more than $25 billion in annual operating profits. And they represent more than $1.1 trillion in shareholder wealth.

These juggernauts dominate the majority of the markets in which they compete, while delivering value to customers and investors alike. But which stock is the better buy today?

Two rhinoceroses facing each other

Amazon and Walmart are two of the biggest beasts in the market today. We put them head-to-head to see which is the best choice for your portfolio. Image source: Getty Images.

Optionality

Walmart mainly does one thing -- retail-- and it does it extremely well. The company's massive scale and highly efficient distribution system allow it to offer ultra-low prices on a wide selection of goods that its traditional retail rivals find difficult to match.

Amazon, however, is one of the few companies that is able to compete effectively with Walmart. The e-commerce titan's global fulfillment network allows it to offer a broad selection of goods at prices that are competitive with -- and oftentimes even lower than -- Walmart's. Moreover, Amazon's constantly expanding network of third-party merchants complements its own product lineup, thereby providing an even broader selection of goods for its customers to peruse.

Perhaps most importantly, Amazon's popular Prime membership program helps to lock consumers into its ecosystem by providing free-shipping options, special discounts, and easy repeat-purchase features. Together with its third-party merchant network, this gives Amazon a nearly unassailable competitive position in online retail. In fact, as my colleague Adam Levy notes, Amazon is expected to sell more goods online than all of its competitors combined in the next year.

In addition, Amazon is far more than just a retailer. Amazon Web Services (AWS) is the dominant cloud-computing infrastructure service in the world. Amazon is also the leading provider of smart-speaker devices -- an increasingly important area as smart-home technology gains mainstream adoption. And its rapidly growing digital advertising business is quickly becoming another powerful source of growth. These ancillary businesses help to reinforce and strengthen Amazon's core e-commerce operations. They also give Amazon more ways to win -- and for its shareholders to profit -- in the years ahead.

Advantage: Amazon

Financial strength

Now let's see how Amazon and Walmart compare with regard to their financial fortitude.

Metric

Amazon

Walmart

Revenue

$193.19 billion

$500.34 billion

Operating income

$5.03 billion

$20.44 billion

Net income

$3.94 billion

$9.86 billion

Operating cash flow

$18.26 billion

$28.34 billion

Free cash flow

$5.36 billion

$18.29 billion

Cash

$24.96 billion

$7.89 billion

Debt

$44.49 billion

$46.61 billion

Data sources: Morningstar, Yahoo! Finance.

Amazon has the stronger balance sheet, with $17 billion more in cash reserves. Walmart, however, generates 2.5 times more revenue, four times the operating profits, and 55% more operating cash flow than Amazon. So I'll give the edge to Walmart for financial strength.

Advantage: Walmart

Growth

Walmart's profit and cash flow production may be greater, but Amazon is growing much faster.

Amazon's revenue is forecast to surge by 33.5% in 2018 and 22.5% in 2019. Additionally, Wall Street expects Amazon's earnings per share to grow by more than 27% annually over the next five years, fueled by the continued expansion of its core e-commerce business, digital advertising platform, and AWS.

Walmart, on the other hand, is expected to increase its sales by only about 3% annually over the next two years, driven primarily by e-commerce gains and low-single-digit comparable-store sales growth. Moreover, analysts estimate that Walmart's EPS will rise by less than 6.5% per year over the next half-decade, as it continues to spend heavily to strengthen its e-commerce technology and build out its international operations.

Thus, Amazon has a substantial edge in terms of expected sales and earnings growth in the years ahead.

Advantage: Amazon

Valuation

Finally, let's see how these retail giants compare on some key value metrics.

Metric

Amazon

Walmart

P/S

4.56

0.51

P/FCF

164.19

14.21

Trailing P/E

228.14

29.38

Forward P/E

89.74

17.65

PEG

5.32

2.81

Data source: Yahoo! Finance.

Whether its price-to-sales, price-to-free cash flow, or price-to-earnings, Amazon's stock is substantially more expensive than that of Walmart. This is to be somewhat expected, due to Amazon's vastly higher projected growth rates. But even if we account for this -- which is what the price-to-earnings-to-growth (PEG) ratio does -- Amazon's shares are still much more richly priced. Walmart's stock is significantly cheaper based on these traditional valuation metrics. 

Advantage: Walmart

The better buy is...

Ultimately, you'll need to decide which of these factors is more important to you.

Growth investors will no doubt gravitate toward Amazon. The company has strong competitive advantages in multiple high-growth markets, which give long-term investors many ways to win. Value investors, however, will likely appreciate Walmart's superior free cash flow generation and more attractively priced shares.

Either way, if you decide to buy one of these stocks, you'll be investing in a high-quality business. And in the end, investors seeking to profit from the massive long-term opportunity in global commerce may wish to invest in both Amazon and Walmart.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Joe Tenebruso has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Amazon. The Motley Fool has a disclosure policy.