Apple (AAPL 2.59%) and Amazon (AMZN 0.37%) are two of the most recognizable brands in the consumer market. One dominates in tech devices, holding leading market shares in most of its product categories. Meanwhile, the other is the world's biggest e-commerce firm, with a lucrative cloud business to boot.

These tech companies have revolutionized their respective industries and are continuing to innovate, making their stocks attractive long-term options. However, before filling up on shares in Apple and Amazon, make the most of your investment by determining which is the better buy. Just because a company leads its industry doesn't necessarily mean its stock trades at the right price.

So, let's assess whether Apple or Amazon is the better stock to buy right now.

Apple: The cash to go the distance

As the world's most valuable company with a market cap of nearly $3 trillion, Apple has a long history of offering investors consistent gains. The tech giant has faced challenges over the last year as macroeconomic headwinds curbed consumer spending and led to repeated declines in product sales. However, its balance sheet remains an attractive reason to invest, with the company on solid financial footing despite difficult market conditions.

AAPL Free Cash Flow Chart

Data by YCharts.

Apple ended its fiscal 2023 with nearly $100 billion in free cash flow and $162 billion in cash and marketable securities. In fact, as seen in the table above, Apple has significantly more free cash flow than some of its biggest competitors.

Market declines may have sent revenue tumbling 3% year over year in 2023, but the iPhone maker is a reliable buy with the funds to overcome current hurdles and continue investing in high-growth markets.

For instance, Apple's research and development spending rose by $3.6 billion this year, with much of that going to its expansion in generative artificial intelligence (AI). The company isn't as far into its AI journey as other tech giants, but it has the brand loyalty and cash to go far in the sector.

Amazon: Growth prospects in multiple markets

Wall Street has grown particularly bullish about Amazon this year, with its stock up 72% since Jan. 1. The company has rallied investors with a return to profitability in its e-commerce business and an expanding role in AI.

Amazon may have started out as an online book retailer in 1994, but it has expanded to so much more. The company became a behemoth in tech, profiting from the development of several markets.

According to Statista, e-commerce sales made up about 19% of all retail purchases globally in 2022. That figure is expected to hit 23% by 2027, with Amazon well positioned to see major gains from that growth.

Moreover, the company has achieved a lucrative position in the cloud market with Amazon Web Services (AWS). The cloud platform is responsible for a 32% market share, significantly ahead of competitors Microsoft's Azure and Alphabet's Google Cloud. Meanwhile, AWS delivers attractive profit margins of about 30%, allowing the company to lean less on its retail business amid economic challenges.

Amazon's dominance in cloud computing could play to its advantage in the AI market as businesses increasingly seek AI tools to boost efficiency, and the company continues adding such services to AWS.

Is Apple or Amazon the better stock to buy?

Apple and Amazon likely have bright futures, and it's hard to go wrong with either over the long term. These companies are favorites among consumers, having built up immense brand loyalty with their users.

However, when comparing both companies' price-to-earnings ratios (P/E) and price-to-free cash flow ratios, it looks like shares in Apple currently offer more value. See the chart below.

AMZN PE Ratio Chart

Data by YCharts.

P/E and price-to-free cash flow are useful metrics to determine a stock's value. For both, the lower the figure, the cheaper the share price.

Apple's P/E of 31 and price-to-free cash flow of 30 aren't exactly major bargains. However, they are significantly lower than the same metrics for Amazon. Apple's solid financials and wealth of cash mean its stock is trading at a more attractive price point, with its shares the better buy right now.