Twinkies in display at the Hostess Brands’ bakery in Denver in 2013. Almost four years after seeking bankruptcy protection, the maker of Twinkies and Ding Dongs is set to again take the stage as a publicly traded company. (AP Photo/Brennan Linsley, File)

In 2012, the end appeared nigh for the humble Twinkie, the yellow sponge cake and American icon: A trend toward healthy eating and a bitter union brawl had forced its baker into bankruptcy.

Now, Hostess Brands is back with a vengeance, with new plans to become a publicly listed company and return to a market that had once left it for dead. The deal, announced Tuesday, would give the maker of Twinkies, CupCakes and Ding Dongs a market value of roughly $2.3 billion.

The sweets giant has in recent years staged a remarkable revival, spearheaded by a billionaire turnaround artist and promoted in company marketing as “the sweetest comeback in the history of ever.”

But its private-equity-fueled resurgence has also revealed some of the grim costs paid to keep the failing business alive. The company has shed thousands of workers, closed most of its decades-old bakeries and changed the face of one of the country’s most timeless junk-food brands.

“We like to think of ourselves as a billion-dollar startup,” Hostess chief executive Bill Toler said Tuesday on an investor conference call.

Hostess’ owners — Metropoulos & Co., led by billionaire food-industry investor C. Dean Metropoulos, and Apollo Global Management, a private-equity firm — said they had reached a deal designed to get the company listed on the Nasdaq stock exchange by this fall. That public debut would allow the company to raise money from shareholders to pay down debt, invest in upgrades or fund potential takeovers of outside companies.

The owners will sell most of Hostess Brands in exchange for about $725 million from a team of investors led by the Gores Group, the Los Angeles private-equity firm that will take the company public. Apollo and Metroupoulos, which bought the company out of bankruptcy in 2013 for $410 million, will retain a 42 percent stake. Metropoulos, the company’s executive chairman, and William Toler, its chief executive, will stay on in their current roles.

“Hostess presents a unique opportunity to invest in an iconic brand with strong fundamentals that is poised for continued growth,” Gores Group chairman and chief executive Alec Gores said in a statement. “We look forward to working with the team at Hostess as we collaborate to further capitalize on these attractive growth prospects.”

Hostess was founded in 1919 with the introduction of its swirly-topped CupCake, but its first true hit was the Twinkie, first baked in 1930. Hearty and sweet, the two-for-a-nickel Twinkies proved immensely popular among the penny-pinching Americans of the Great Depression. Its original banana-cream filling was swapped for vanilla during the banana rations of World War II.

The Twinkie’s fame grew in the ’50s, due in part to its major sponsorship of one of the first children’s TV shows, “Howdy Doody.” (A 1958 segment proclaimed them “one of the most delicious desserts we’ve ever had in Doodyville.”) Their chemical sturdiness — a common myth says they won’t spoil for years — helped secure their place in lunchboxes and bomb shelters. In 1999, President Bill Clinton selected the iconic American treat as one of the keepsakes in the nation’s millennium time capsule.

In the years that followed, corporate watchers of Hostess worried that the Twinkie was threatened with extinction. A national trend toward more wholesome snacks tightened the belt on the snack cakes’ sales, and weighty pension costs and tense labor negotiations made them costlier to make. The company filed for bankruptcy in 2004, emerged from its restructuring in 2009 and filed again in 2012, selling off assets and calling for an end to snack-cake production.

When Apollo and Metropoulos bought the company, they restarted the bakery conveyor belts and used the failure as a marketing tool: Advertising on billboards and in social media, where the uproar over the cakes’ demise was most vocal, proclaimed, “An icon returns.”

Under the new owners, Hostess regained market share by advertising or relaunching much of its overflowing pantry of dessert brands, including Ho Hos, Fruit Pies, Ding Dongs and Donettes. It expanded further into grab-and-go points, including dollar stores and vending machines, that its previous owners had largely ignored. And it tweaked the recipes, investing millions in chemical research to expand its snack-cake shelf life to an average of 65 days.

The once-bankrupt company is again booming, pulling in $650 million in revenue in the 12 months ending May 31, filings show. But along the way, management has carved deeply into its workforce.

Where the company just five years ago had 8,000 employees — 75 percent of whom were represented by unions — the company now says in filings that it has a “streamlined employee base” of roughly 1,170 workers. That workforce is the shadow of a once-vast empire, which shortly before its troubles totaled 22,000 workers across more than 40 bakeries.

The company has invested $130 million to upgrade production lines and industrial ovens in its three core bakeries in Indianapolis; Emporia, Kan.; and Columbus, Ga. Its other bakeries have disappeared: The company in 2014 announced it would shutter its long-running bakery in the Chicago suburb of Schiller Park, where the Twinkie was first baked. About 400 jobs were affected.

Based in Kansas City, Mo., the company has closed all 600 or so of its Hostess outlet thrift stores and now delivers directly to warehouses, helping avoid the inefficiencies of regional bakeries, small distribution lines and direct-to-store delivery.

The cuts have not limited Hostess’ ambition — or its ability to capture public attention. This year, it will sell frozen “Deep Fried Twinkies” exclusively at Walmart, as well as limited-edition “Key Lime Slime” Twinkies, a tie-in with the upcoming “Ghostbusters” film.

“This new phase in Hostess’ evolution,” Metropoulos said in a statement, would lead to “significant reach and potential long into the future. We are very excited to continue to build this wonderful company and its iconic brands.”