Fast-food restaurants have proven to be relatively resilient amid inflation. Even as costs and wages have gone up, popular chains have been able to raise prices and generate positive year-over-year growth. Some are even still growing at rates of 10% or more.

McDonald's (MCD -0.91%)Restaurant Brands (QSR 1.03%), and Starbucks (SBUX 0.47%) are all companies that are still generating strong results through the first half of the year. But that doesn't mean all of them are good buys right now. Let's review.

Top brands are still doing well

Comparable sales growth is a key metric for restaurants because it excludes stores that have closed and ones that have recently opened. It gives investors a more reliable growth rate since it only considers the restaurants that were also open at the same time last year; there's no artificial boost from simply opening up more locations.

Four chains that have been doing well this year are McDonald's, Tim Hortons, Burger King, and Starbucks (Restaurant Brands owns Tim Hortons and Burger King). They have all been reporting comparable sales growth of 10% or more through the first two quarters of the year. Although there has been a dip in some of those growth rates over the past few years, these businesses are, for the most part, doing well above average. 

Fast food comparable sales by quarter.

Image source: Company filings. Chart by author.

I've added Chipotle, which is known for its fast-growing operations, as a comparable to show that even its recent results aren't as impressive, as its growth rate has slowed considerably from where it was a few years ago.

Should investors expect a slowdown?

While consumers have continued to eat out even as prices have been rising, the danger is that the cumulative effect of all the increases may eventually lead to a drop in demand. And now, with the inflation rate also slowing down, there may be less room for restaurants to raise their prices. That means they'll have to rely more on increases in demand rather than just higher prices in order to generate growth, which may not be an easy task.

Another headwind for these fast-food chains is that they will be going up against stronger comparables in future quarters, which will make it more difficult for them to continually post high growth rates. Starbucks and other companies benefited from reopenings in China earlier this year, but in a few quarters they'll be lapping those results, and their growth rates may not look nearly as strong.

Accounting for a margin of safety

Buying stocks at high valuations can be risky, particularly if their growth rates start to slow down. Investors should consider buying stocks on the lower side so that they can factor in a margin of safety in case a company's growth rate slows down. Here's how those top fast-food chains compare when looking at their respective price-to-earnings multiples.

MCD PE Ratio Chart

MCD PE Ratio data by YCharts

The S&P 500 average is 20, and the only one of these stocks that is near that multiple is Restaurant Brands.

Buy Restaurant Brands, hold off on the rest

Restaurant Brands provides investors with the best value of the fast food stocks listed here. Two of its chains, Burger King and Tim Hortons, are growing at rates of more than 10%. That gives it more diversity than a McDonald's or Starbucks stock, where a lot hinges on just a single brand. Another reason to buy it is for its dividend. At 3.2%, Restaurant Brands offers a higher yield than McDonald's and Starbucks, which are both around 2.2%. 

Investors need to prepare for the possibility of a slowdown, because if that does happen, stocks such as McDonald's and Starbucks could slide sharply given their inflated valuations. Restaurant Brands, at a more modest price, gives investors a better buffer, and thus is the only fast food stock I'd buy today.