Shares of Costco Wholesale (COST 0.17%) are a perennial favorite for good reason. The warehouse retailer is practically recession-proof, and it has delivered elevated revenue growth since the beginning of the pandemic -- more than two years already. Its stock has gained about 90% since that time.

But at its current price, Costco stock trades at 42 times trailing 12-month earnings. The price-to-earnings (P/E) ratio is one metric that helps investors determine how accurately a stock is valued. Is the current price a lot to pay for this specific stock? Or is it inexpensive relative to what it offers?

All stocks at the same price are not equal. If a stock with a four-digit price tag is posting high growth, or delivers a lot of income, it could be a much better value and be considered "cheaper" than a stock with a two-digit price tag. Alternatively, a stock with a low price might be "expensive" when measured against its growth opportunities.

Stocks in Costco's class generally sport lower P/E ratios. Walmart stock trades at 27 times trailing 12-month earnings, and Target is at 18. BJ's Wholesale Club, perhaps the retail stock most similar to Costco, trades at a P/E of 23. Costco trades at about double these valuations. Is it too expensive right now? Or does its high valuation signal something more?

Why Costco stock costs more

Costco operates a fee-based retail model where shoppers buy an annual membership to shop at its warehouses. BJ's and Walmart's Sam's Club have a similar model. Customers are willing to pay this fee because Costco's prices are that much cheaper than your average supermarket.

Chief Financial Officer Richard Galanti has said that Costco's average gross margin is 11% to 12%, implying about a 13% markup -- way below the industry average, which is in the mid-20s or more. A basic Costco membership costs $60 annually. While in any given period, people flock to Costco's warehouses to take advantage of its low markups, it becomes a significant edge under challenging global economic conditions.

Year over year, Costco's sales historically have increased at high single-digit rates, on average, with reliable growth in net income, making it a terrific value stock. Since the pandemic started, Costco's quarterly sales increases have been averaging in the mid-teens year over year. 

Even as companies like Target and Walmart, which are also discount retailers, have seen a marked slowdown in 2022, Costco has not. Sales increased 16% in the third quarter (ended May 8) over last year. Earnings per share rose from $2.75 last year to $3.04 this year, despite supply chain pressure and a pre-tax charge related to increased wages. It did feel some heat with margins, however, and the gross margin fell from 11.18% last year to 10.19% this year.

Costco's ability to generate higher sales consistently as well as turn them into profits has impressed investors, and this has led to an elevated P/E as compared with its peers even before the pandemic, when it hovered around 30. As Costco continues to demonstrate strong performance under challenging circumstances, the P/E ratio has been creeping up.

COST PE Ratio Chart

COST PE ratio. Data by YCharts.

Is it worth it?

The very short answer is yes. But let's explain. Costco stock has consistently delivered gains for shareholders over many years. If you are a long-term investor, you can view Costco's fundamentals as indicative of future growth. In total, Costco operates 830 warehouses, including 574 in the U.S. It opens stores at a fairly slow pace, around 25 to 30 a year. It has ample room to open more, on top of consistent comps growth. 

A P/E of 42 is expensive as compared to peers, but are its peers really equal? Investors have assigned Costco stock a higher valuation because they have more confidence in its chances. So 42 is not a nosebleed growth-stock valuation. It could be reasonable for what Costco offers.

And you can't time the market. The chart above shows that there have been pullbacks over the past two years, and investors might decide to wait for another one before buying in. But you don't know when and if that will happen. If you plan to build this stock into part of a long-term portfolio, Costco is a buy even at this price.