Mattress Firm, the country's largest mattress chain, filed for bankruptcy Friday, the latest retailer to succumb to mounting online competition.

The Houston-based company, which has 3,400 locations nationwide, plans to close 200 stores in the coming days and as many as 700 by year's end, according to its bankruptcy filing. In the Philadelphia region, Mattress Firm, which also owns the Sleepy's mattress chain, will immediately close its outlets on West DeKalb Pike in King of Prussia; at the Grant Plaza in Northeast Philadelphia; two stores in Lancaster; one in Reading; and one on the White Horse Pike in Hammonton, N.J.

The company said it does not anticipate delayed deliveries and will keep paying its suppliers in full.

Mattress Firm is the latest in a string of national retailers, including Brookstone and Nine West, to file for bankruptcy as consumers increasingly shop online. The company, founded in 1986, has long had a hold on the mattress industry. In 2015, it bought rival Sleepy's for $780 million and announced plans to expand throughout the Northeast and Mid-Atlantic regions.

But analysts say the company had too many locations — and did too little to keep up with the crush of online competitors.

Bankruptcy expert Ted Gavin of Gavin/Solmonese, who worked the Chapter 11 bankruptcy cases for two major bedding companies, said the industry has consolidated and "disintermediated."

"It's amazing what a frenzied acquisition streak will do to a company's stability. When I was working the Rockaway Bedding Chapter 11 case, Mattress Firm wasn't on anyone's mind as an industry-wide player," Gavin said. "Later, when working the Mattress Gallery Chapter 11 case, nobody was talking about Mattress Firm. Three giant acquisitions later, here they are with too much real estate and too much inventory."

According to Gavin, Mattress Firm is $3.56 billion in debt with assets of about $2.5 billion.

Bob Phibbs, chief executive of New York-based consultancy Retail Doctor, said buying a mattress often felt like buying a used car. Customers weren't sure how to compare one model to another, and the barrage of promotions and discounts made them feel insecure about whether they were getting a good deal.

"This is a wake-up call for traditional mattress chains: The 1960s model doesn't work anymore," said Phibbs. "The traditional mattress-buying experience didn't make people feel like they mattered. It made them feel used."

"The reality is that mattress companies have been ripe for disruption," Phibbs said.

Mattress Firm's bankruptcy filing comes just days after announced it was getting into the online bed-in-a-box business, popularized in recent years by the likes of Casper, Tuft & Needle, and Leesa. Walmart launched its own online premium mattress brand, Allswell, this year. The basic premise of each brand is the same: Buy a mattress online and try it at home. If you don't like it, you get a full refund.

Mattress Firm has had other woes. Last year, it lost an important contract with Tempur Sealy International, and its parent company, Steinhoff International Holdings, has been mired in an accounting scandal.

"Leading up to the holiday shopping season, we will exit up to 700 stores in certain markets where we have too many locations in close proximity to each other," Steve Stagner, chief executive of Mattress Firm, said in a statement. He added that the company would use the money it saved from store closings to "improve our product offering, provide greater value to our customers, and strategically expand in existing markets where we see the greatest opportunities to serve our customers."

Staff writer Sam Wood contributed to this article.