Hold on to your retail stocks, investors. 

Apparel sales may have dipped 2% in 2017, according to the latest report from NPD Group, but retailers across the board have an age-old trick up their sleeve: the private label.

J. C. Penney Company Inc. (JCP) is the latest to unveil a private label line, called Obsess, which caters to Gen Z teenage girls, the company announced Wednesday, Feb. 21. That's on the heels of reports that Walmart Inc. (WMT) will be introducing a number of new private labels for women and kids to replace the older lines Faded Glory, DanskinNow and White Stag.

Meanwhile, Target Corporation (TGT) is making good on its promise to deliver a dozen new private label brands by 2019, including a handful of new ones in apparel. The three  — A New Day, Goodfellow & Co. and Joy Lab — which came out in the third quarter have already posted strong sales, Chief Merchandising Officer Mark Tritton said during the earnings call last November.  In addition, within a year of launching in 2016 its new kids brand, Cat & Jack, the line's revenue reached $2 billion.

Macy's Inc. (M) also announced plans to step up the private label game, aiming for in-house brands to make up 40% of its merchandise mix by the end of 2017. Then, of course, there's Amazon.com Inc. (AMZN) . The e-commerce behemoth has 19 apparel private brands as of December, including at least four athleisure brands released since the summer.

So why are big box chains investing in clothes when U.S. apparel sales fell last year, to $215 billion, and even the growth of online apparel sales has drastically slowed?

It's all about margins, sources told TheStreet, and the chance to stand out with fresh designs in a overcrowded field. When a retailer carries lines from third-party vendors, the profits are split between the two. With private lines, vendors are kept out of the picture and the retailer reaps the gains. 

Even Amazon, which dominates online searches for clothing products, must invest in private labels in order to avoid dependency on its relationships with established vendors like the PVH Corp.-owned (PVH) Calvin Klein and Nike Inc. (NKE) , according to Tom Gehani, director of retail client strategy at research firm L2.

"Apparel is usually the highest margin portion of retail businesses, so as consumers spend less on apparel, their overall sales are disproportionately affected," he told TheStreet. "From an investor standpoint, private labels could really help with their bottom lines."

Another compelling reason to invest in private label for retailers is the chance to differentiate oneself among a sea of choices for consumers.

"Just about everyone I know shops online in a thousand different ways," said Lee Peterson, executive vice president at retail consultancy WD Partners Inc. A Google search for Levi's 501 skinny jeans for women, for instance, shows at least 10 different retailers: for example, $40 from Levis.com, $39.99 from Zappos, and $59.50 from J.C.Penney.

The price variation, in fact, is part of why apparel sales have dipped, Gehani explained. "Prices are just lower now for these established brands and customers are better at finding the best ones," he said. "But when you have your own private label, that's a reason to come to your store instead of Amazon's search box or Google."

The dismal state of the apparel industry may also be encouraging for retailers, according to Peterson, because it levels the playing field for these chains. "It's much easier to infiltrate something when it's afflicted," he said. "It's weak right now, so let's give it a shot."

Private label offerings are also typically cheaper than brand-name alternatives, which are popular with all consumers, particularly millennial shoppers. With millennials gaining more spending power as they mature, retailers anticipate that they will become the primary driver of sales. 

J.C. Penney shares were up 2.3% at Thursday's close, trading at $3.94. Walmart's stock was also up, with shares rising nearly 1.4% and trading at $92.77.

Amazon is a holding in Jim Cramer's Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells AMZN? Learn more now.

More from Stocks

Google Shares Shrug Off $5 Billion EU Fine Against Alphabet

Google Shares Shrug Off $5 Billion EU Fine Against Alphabet

Jim Cramer's Biggest Moments From Delivering Alpha

Jim Cramer's Biggest Moments From Delivering Alpha

The Recent Pullback in the Defense Sector Provides a Buying Opportunity

The Recent Pullback in the Defense Sector Provides a Buying Opportunity

Video: What to Expect From Microsoft's Earnings Thursday

Video: What to Expect From Microsoft's Earnings Thursday

Lee Munson on Why Investors are Shifting to Small-Cap Stocks

Lee Munson on Why Investors are Shifting to Small-Cap Stocks