Comfort foods tend to thrive during times of economic uncertainty, especially those that are inexpensive. Packaged foods purveyors have shown resilience throughout the pandemic and ensuing inflationary fallout.

However, to curb increased labor, supply chain, and raw materials costs, food suppliers have raised prices over the past year, which can be a slippery slope if consumers are forced to trade down for generic knockoffs.

Let's take a look at two snack food companies that have shown particular strength over the past few years, and determine which makes a better buy in today's market. 

The case for Hostess Brands

After reaching an all-time high of $29 last November, shares of Hostess Brands (TWNK) have since fallen more than 21%. Investors must now weigh the Twinkie maker's past performance and future outlook to determine whether this dip is worth buying or not.

Hostess enjoyed record sales of $346.2 million in Q3 of 2022, a more than 20% increase in organic net revenue year over year. The sweet baked goods category, which accounts for nearly 90% of total sales, grew 18.7%. Cookie sales, in particular, jumped 33.2% versus Q3 of 2021, thanks largely to Hostess' strategic acquisition of the popular Voortman Cookies brand in 2020.

Despite record sales, profitability has been strained for Hostess, primarily due to inflation and a disrupted supply chain. To counter diminishing margins, Hostess has implemented a series of price hikes to cushion its net profit margin

With future price hikes now reserved as a last resort, CEO Andy Callahan affirmed Hostess' commitment to recovering its gross margin with comprehensive efficiency improvements across company operations. In a show of confidence, Hostess also raised its 2022 full-year guidance from 15% to 17%-19%. 

The case for J&J Snack Foods

J&J Snack Foods (JJSF -0.04%) stock dropped more than 10% over the past month and now trades roughly 24% below its all-time high from 2019. But the company has posted four straight quarters of record revenue, so investors are likely questioning whether or not to buy the dip on J&J Snack Foods -- known most for the SuperPretzel, ICEE, and now Dippin' Dots. 

The New Jersey-based snack foods purveyor racked in a record $400.4 million in net sales during the fourth quarter of its fiscal 2022, enjoying growth across its food service lines -- churros, soft pretzels, and most of all frozen novelties. 

Having acquired the world-famous Dippin' Dots brand in Q4, J&J more than tripled its frozen novelties revenue during the quarter. Excited to keep pushing Dippin' Dots into under-penetrated markets, CEO Dan Fachner avowed that the Dippin' Dots brand "aligns perfectly" with J&J's existing portfolio of snack foods and overall business model. Expansion efforts have been working so far, with Dippin' Dots posting 18% year-over-year growth in the fourth quarter.

Regardless of strong sales, increased transportation and raw materials costs have impacted profitability in recent quarters. For example, despite record revenue, Q4's net profit of $17.3 millionmarked an 8.3% drop year over year. Undeterred by the current economic climate, Fachner and his team have implemented a combination of price increases and cost-saving initiatives, and he assures "the best is yet to come" for J&J Snack Foods.

Which consumer staples stock is a better buy?

Since both of these consumer staples stocks have a similar market capitalization, let's compare their price-to-earnings ratios to determine which one makes a better buy in today's market. We'll also look at both companies' price-to-book ratios and one-year growth estimates to paint a more comprehensive picture.

Metric Hostess Brands J&J Snack Foods
Market capitalization $2.98 billion $2.88 billion
Price-to-earnings ratio 18.6 60.8
Price-to-book ratio 1.7 3.3
One-year forward EPS growth rate* 13.4% 18.5%

Data source: Yahoo finance, *analysts' average estimate

With both a lower price-to-earnings ratio and price-to-book ratio, Hostess emerges as today's winner. But due to recent company developments and a more robust earnings growth outlook, J&J Snack Foods also appears to be a solid long-term investment. Between these two well-loved sweet treat creators, you really can't go wrong.