When Warren Buffett talks, investors listen. On May 3, the illustrious stock picker quipped that "we are seeing very substantial inflation." Buffett's observation was right. But the good news is that even though inflation can be dangerous for your portfolio, investors aren't powerless in the face of rising prices and falling purchasing power per dollar. In fact, picking the right set of stocks could go a long way toward weathering the storm.

Businesses that are price makers rather than price takers will likely fare better during this inflationary period because they will have the freedom to adjust pricing to stay consistent relative to the real cost of inputs. Likewise, companies that sell consumer essentials will be hardier in the face of inflation than those that sell luxuries, as people will still need certain goods whether or not those goods cost more money. With these properties in mind, let's examine two stocks that I expect will have no problem staring down inflation.

Person sits on couch at home leaning over a coffee table, writing on a piece of paper with a pen.

Image source: Getty Images

1. Johnson & Johnson

Johnson & Johnson's (JNJ 0.69%) portfolio of consumer products is worth around $14 billion per year, and it includes everything from moisturizers and mouthwash to Tylenol, eye drops, and Band Aids. While it's true that there are a plethora of alternatives on the market for these products, it's also the case that consumer demand isn't going to change very much even if prices rise. After all, inflation will affect the companies that make competing products too -- and they're just as capable as Johnson and Johnson when it comes to naming their price, so long as they don't go too far above what the competition is asking. 

In short, Johnson & Johnson can pass any increases in the price of its raw materials on to consumers, and there isn't much they'll be able to do about it. Nobody is about to do without Tylenol, and it's inconceivable that healthcare systems would entertain the idea either. As a result, investors don't need to worry much about its 17.95% profit margin eroding. Importantly, J&J also has a $45.6 billion portfolio of prescription-only pharmaceutical drugs for conditions like multiple myeloma and other cancers, not to mention its coronavirus vaccine. Much like with its consumer health goods, these medicines can be priced to whatever the market can support, and its customers in healthcare will simply pass the costs on to insurers. 

Thus, with multiple business segments where it can name prices, it's hard to see how Johnson & Johnson would fare poorly in the face of inflation, especially considering that the company has faced down more aggressive periods of inflation in the past.

US Core Inflation Rate Chart

US Core Inflation Rate data by YCharts

2. Costco Wholesale

Costco Wholesale (COST 1.09%) is a notoriously price-conscious company. People flock to its warehouses to get cheap groceries and daily consumer goods in bulk. With a gross margin of close to 11%, which actually increased slightly during the disruption of the pandemic in 2020, it's clear that the company is exceptionally scrappy. And because Costco gates access to its stores with a membership fee, it's in a decent position to combat the impact of inflation right off the bat because it can simply charge members more to keep pace with rising prices elsewhere. 

But, there's one issue: Management is loath to raise prices, even for trivial products like the hot dog and soda combo, which has been priced at $1.50 since 1985. Thankfully, the Kirkland brand of products could be an easy way out of this conundrum. Because Costco is known for being a low-cost bulk seller, it doesn't need to increase prices whatsoever to keep its margin intact. Instead, it can use its control over Kirkland products to repackage them such that consumers get slightly less for their dollar.

This process is called shrinkflation, and it's a tactic that Costco is uniquely positioned to implement, perhaps even without putting off any of its customers. If inflation starts to run wild, Costco can cut back on how much it offers on its lowest-margin products, thereby protecting themselves without passing on higher sticker costs. Of course, they're probably not about to change the hot dog and soda combo to have a smaller cup or a shorter dog, but the point is that they could do it if they wanted to, and people might not even notice. So, if you're looking for a long-term buy-and-hold stalwart that's also ready to continue business as usual during inflation, it's hard to do better than Costco.