Image source: Getty Images.

There are a few publicly traded packaged-foods companies to invest in despite industry headwinds. The industry is struggling to find growth as people move away from popular, branded snacks toward cheaper and/or healthier options, especially organic. That shift has left many big-brand companies posting sales and profit declines. Yet a handful of food stocks are beating the broader market so far this year in spite of the weak selling environment that they're in.

Here's a look at the biggest winners so far in 2016:

Food stocks beating the market

Stock

Market Capitalization

Profit Margin

Kraft Heinz

$109 billion

9%

McCormick

$12 billion

10%

J.M. Smucker

$16 billion

9%

General Mills

$39 billion

10%

Hershey

$21 billion

10%

Data source: Yahoo Finance.

Kraft Heinz (KHC 1.80%) tops the list with a 23% gain compared to the market's 6% -- but that's not due to any especially strong operating trends. In fact, organic growth fell by nearly 1% in the company's most recent quarter as sales volume declined in key segments including cheese, deli meats, and coffee. "There is still much work to be done," CEO Bernardo Hees told investors in early August. Investors are excited about the prospects of continued integration in the Kraft and Heinz merger, though, which produced a 160% sales jump last quarter. Yet the stock isn't likely to produce long-term gains until the company can get back to consistent organic growth.

J.M. Smucker (SJM 3.29%), the company behind the Smucker's, Jiff, and Pillsbury food brands, is also hoping that a major acquisition will help reinvigorate growth. Its new pet-food division has turned into more of challenge than initially expected, though, and so management recently had to walk back their 2017 sales forecast. Smucker should post a slight organic sales decline rather than the tiny uptick that executives originally projected. The snack specialist's rising profitability continues to impress as gross margin, fueled by innovations in the coffee business, rose to a recent high of 39% of sales -- up from 37% a year ago.

Thanks to its dominant position in the candy business, Hershey (HSY 0.09%) enjoys even higher profitability -- at 45% of sales. Shareholders have been on a roller-coaster ride this year after another bid to acquire the global confection giant fell apart, but the stock is still beating the market even as investors conclude that Hersey isn't likely to be bought out any time soon.

Hershey is growing at a slightly faster pace than peers, with organic growth expected to be about 2% this year. Investors have to balance that stronger profile against one of the biggest premiums in the industry: Hershey is valued at 28 times earnings, compared to 23 for Smucker.

General Mills (GIS 1.93%) is seeing surprisingly weak sales due to what management last quarter described as a "challenging macro environment." Its growth brands -- which target the natural and organic market segments -- failed to make up for falling demand in its legacy cereal and snack products, leading to a 4% organic growth slump. Executives believe they have the right initiatives in place to produce a growth rebound, though. Despite a slow start to the company's 2017 fiscal year, management affirmed their full-year guidance of a roughly 1% organic growth decline. Investors who see the company's stumbles as a short-term problem might be enticed by General Mill's 3% dividend yield -- the highest of this group.

Spicing and flavoring specialist McCormick (MKC 1.68%) is expecting to boost sales by a hefty 5% this year even as earnings and profitability climb. Investors have good reasons to trust that forecast, including the fact that higher volume and rising prices last quarter helped net income improve to 9% of sales from 8% in the prior-year period. Unlike peers on the above list, McCormick is benefiting from rising demand in its industry -- which management intends to capitalize on. "We are meeting this demand with an expanding portfolio of on-trend products," CEO Lawrence Kurzius said in a late-June press release.

Two solid investment candidates

McCormick and General Mills are the two names I like best on this list. McCormick has the strongest operating outlook, and its cash flow -- up 15% in the last six months -- points to solid financial returns to shareholders ahead. Meanwhile, General Mills looks like an attractive turnaround bet given that its P/E ratio of 23 makes it relatively cheap.

Like all of the food stocks on this list, General Mills has become more expensive this year. Still, investors are likely right in their growing optimism that a few big-brand food giants can succeed by adjusting their portfolios to meet quickly changing customer preferences.