Macy's at Chula Vista Center prepares for the Grand opening of its off-price shopping experience, Macy's Backstage, on Wednesday, Sept. 12, 2018 in Chula Vista, Calif.

Shares of retailers took a thrashing Wednesday with Macy's and Dillard's leading the rout, tumbling by 16 percent and 10.8 percent, respectively.

J.C. Penney fell 8.7 percent to $2.41 a share, Kohl's fell 5.8 percent to $74.39 and Nordstrom's fell 5.5 percent to $51.86. Macy's closed at $35.15 a share and Dillard's at $82.98.

Even Amazon wasn't immune, following the group as its shares fell 1.9 percent to $1,882.62 a share.

Retailers are grappling with higher commodity costs and tariffs as the Trump administration escalates its trade war across the globe. Stores are also struggling to grow sales amid declining foot traffic and increased competition online. The broader markets were similarly down for the day.

Macy's shares tumbled even after the department store operator reported quarterly earnings and sales that topped analysts' expectations and hiked its forecast for the full year.

"Macy's is certainly playing a role across the entire department store sector [sell-off], but the investor skittishness may be due more to caution on the retail sector's sharp spike upwards in stock prices this year, than to any performance issue at Macy's," Customer Growth Partners President and founder Craig Johnson told CNBC.

According to Jefferies analyst Randal Konik, retail stocks for the most part have had a "great run" so far this year, so Wednesday's sell-off should be viewed as "just a breather."

The National Retail Federation released an upbeat report Wednesday, saying that July retail sales rose 0.4 percent on a seasonally adjusted basis from June and increased 4.9 percent on an unadjusted basis year over year, giving the industry a solid kickoff for the third quarter as consumers continued to spend despite concerns about the growing trade war.

"Consumer spending is the backbone of the current economic expansion but the fly in the ointment is uncertainty regarding tariffs," said Jack Kleinhenz, chief economist at the NRF. "If they escalate, they will no doubt weigh on confidence and household spending."

— CNBC's Lauren Hirsch contributed to this article.