Macy's is taking extreme measures to avoid dire outcomes like bankruptcy, and will try to raise billions in debt to weather the pandemic crisis, according to people familiar with the matter.

The country's largest department store is looking at raising as much as $5 billion in debt, the people said. It will seek to use its inventory as collateral to raise $3 billion and real estate to raise $1 billion to $2 billion, they said. It is not planning to pledge its prime Herald Square location in New York as part of the deal, one of the people said.

The retailer earlier this year retained investment bank Lazard to help shore up its balance sheet.

The people stressed that bankruptcy is not a focus for Macy's at this time. But the decision to take on billions in debt for the historically financially conservative company is a sign of the pressure it is facing as its stores have been forced shut and revenue has run dry.

The people requested anonymity because the information is confidential. In a statement provided to CNBC, a spokesperson for Macy's said: "As we have previously communicated, the coronavirus pandemic continues to take a toll on Macy's business. While the digital business remains open, we have lost the majority of our sales due to our store closures."

"Macy's has taken multiple actions to improve our position and improve financial flexibility, including suspending our quarterly dividend, deferring capital spend, drawing on our credit facility, reducing pay at most levels of management and furloughing the majority of our colleagues," she added.

The statement said "the company is also exploring numerous options to strengthen our capital structure."

Macy's, which also owns Bluemercury and Bloomingdales, has roughly 775 stores. As of January, it had sales of roughly $25 billion and net debt of $3.5 billion. Its nearest debt maturity is for roughly $530 million in January 2021. Its shares have fallen nearly 70% year-to-date, giving it a market capitalization of $1.6 billion.

Macy's has for years resisted pressure to monetize its real estate en-masse, including from activist investor Starboard Value when it had a stake in the retailer a few years ago. Retail is a fickle industry, and retailers often prefer a cash cushion for a rainy day fund. Macy's trip through bankruptcy in the 1990's made clear the value of conservative management for the retailer.

But the coronavirus pandemic has been a firestorm for retail, forcing the industry to battle large fixed costs and evaporating sales. Macy's was already seeking to cull costs prior to the pandemic, amid changing shopping habits and an expansive store base. It has said it plans to shut roughly a quarter of its stores over the next three years.

All of Macy's stores have been closed since March 18 in what the company has called an "unprecedented crisis." Even when stores can reopen, unemployment is making consumers mindful of their paycheck, while the virus has made them wary of crowds.

Macy's peers are facing similar challenges, though to differing degrees of alarm.

Nordstrom last week said it had issued $600 million in secured debt financing, in addition to drawing down $800 million on its revolving line of credit. J.C Penney and Neiman Marcus have both missed interest payments, and Neiman Marcus could file for bankruptcy as soon as this week, people familiar with the matter have told CNBC.

Macy's is in a stronger financial position than J.C. Penney and Neiman Marcus. It still has relationships with apparel brands that depend on the retailer to sell their clothes. Its brand name continues to resonate with many Americans.

Still, its financially conservative past may, ironically, add an extra difficulty as it looks to quickly pool together funds. Because Macy's debt was once investment grade, some of it is hamstrung in stricter indentures and restrictions underwritten at a time no one envisioned all retail doors would be shut, the people said.

Meantime, the value of its long sought-after real estate is also unclear, with no one shopping in stores right now and uncertainty as to when they will return.

CNBC's Lauren Thomas contributed to this report