The consumers who fueled the U.S. economy through the pandemic are starting to crack.

Data last week revealed new evidence from companies and the government that household spending is increasingly strained. Families are paring back purchases of items such as electronics and furniture as prices for essentials like food and gasoline have become more expensive. Inflation drove consumer spending in June to a new four-decade high while personal incomes fell when adjusting for inflation and taxes.

Two of the country’s biggest retailers, Walmart Inc. and Best Buy Co. , warned last week that a steeper-than-expected pullback in shoppers’ spending would crimp their profits. The latest financial results also show that many big companies’ profits have held up so far this year by passing along to consumers higher labor and fuel costs.

Changes in spending habits, so far, have been uneven, companies and economists say. Many people are dining out and traveling more after missing chances to do it earlier in the pandemic. Pent-up demand is also fueling sales for automobiles. And some people—especially higher income households—are continuing to shell out for desired items regardless of elevated prices.

Consumer confidence, however, has softened. After raising interest rates for the fourth time this year to battle inflation, Federal Reserve Chairman Jerome Powell said Wednesday that people are going to the grocery store and finding that their budget no longer covers their usual shopping list. On Thursday, the government said that the nation’s gross domestic product contracted for a second consecutive quarter, raising fears that inflation and a slowdown in inventory building and the housing market are dragging the economy into a recession.

“Consumers’ budgets are stretched,” said Sean Connolly, chief executive of Conagra Brands Inc., which makes Slim Jim meat snacks and Healthy Choice meals. “It forces consumers to be very discerning about what they buy and to find the best overall value.”

People are finding that their budget no longer covers their usual shopping list at the grocery store.

Photo: Brandon Bell/Getty Images

Unilever PLC, Procter & Gamble Co. and Kraft Heinz Co. are bracing for consumers to either cut back or shift to lower-priced or value-oriented products amid economic uncertainty. They each reported lower volumes in their latest quarters, meaning people purchased fewer brand items amid higher prices. Church & Dwight Co. , maker of Arm & Hammer branded products, is seeing heightened demand for low-cost laundry detergent, cat litter and other products, said CEO Matthew Farrell.

Store-branded goods from oatmeal to paper towels gained market share in the four-week period ended July 10 from a year ago, according to market-research firm IRI. Typically private-label products cost less than brand-name versions.

Many consumers who weathered the pandemic with the help of government stimulus and fewer expenses of their own are running out of steam. Some of them now face the return of commuting costs, a need for new work clothes and steeper child-care expenses.

John Rawlings, 22 years old, and Gabby Smith, 21, recently moved into a new home in Florence, Ky., to be closer to Mr. Rawlings’s job at a food manufacturer, in part because his hourlong drive to work became too costly. The couple, with 1- and 2-year-old daughters, said they are going without a couch for now in the new place as they work to keep expenses down.

“Sometimes you have to cut back,” Mr. Rawlings said, pushing a cart packed with store-brand groceries through a Walmart. “I just had to ask my dad for help with diapers.”

The couple estimates they spend about $300 a week on groceries, double from a year ago. Ms. Smith said higher grocery costs were a shock at first, but the couple has begun to adjust. Mr. Rawlings, for instance, dropped his initial resistance to buying cheaper, private-label alternatives to name-brand products. The children no longer get toys or new clothes during grocery trips.

“We’re lucky that we’re doing OK and not struggling just to make ends meet,” Ms. Smith said.

“Not yet,” Mr. Rawlings added.

Companies have found that consumers across income levels are still spending on items they need.

Photo: olivier douliery/Agence France-Presse/Getty Images

In McKinney, Texas, Walter Jimenez is working three part-time jobs on top of his full-time career as a teacher. He is a single father with a 14-year-old son who plays hockey and a 16-year-old daughter who loves art. “My son’s hockey stick broke, that’s $300. My daughter is constantly using up art pads. It adds up,” he said.

Mr. Jimenez is searching for a new apartment because he got notified last week that the rent on his two-bedroom apartment is increasing to $1,850 a month from $1,300 a month. “It’s really hard to find anything. I’m having to humbly ask if buildings offer teacher discounts,” he said.

While people are spending more of their paychecks on groceries, rent and gas, U.S. consumers have pulled back on buying electronics, apparel, housewares and small appliances since March, according to market research firm NPD.

At Abt Electronics Inc., an 86-year-old Glenview, Ill.-based electronics and appliance retailer, sales have softened compared with earlier in the pandemic when shoppers flocked to buy computers, televisions and other stay-at-home favorites, said Jon Abt, co-president of the company. “We are definitely seeing a slowdown in categories like that because you don’t need a new computer every year,” said Mr. Abt.

But Mr. Abt said consumers across income levels are still spending on items they need whether it is furniture or appliances. Tumi suitcases, a high-price luggage option in the store, are also selling well after dropping off earlier in the pandemic, he said.

The strains on households appear to be spilling into some services they use. AT&T Inc. said its customers were taking two days longer on average to pay for their monthly internet and wireless bills. Comcast Corp. failed to add to its ranks of broadband customers for the first time in its history. Netflix Inc. has reported declines in subscribers in each of the past two quarters.

Several restaurant chains, including McDonald’s Corp. and Chipotle Mexican Grill Inc., have said that lower-income consumers are dining out less often or buying cheaper food off their menus. Overall restaurant visits and online orders fell 2% in the second quarter versus a year earlier, according to NPD. Consumer restaurant spending, which also reflects higher prices, was up 2%.

A July survey of consumer sentiment from the University of Michigan showed little change from June, when it hit historic lows. Every recession in the survey’s 76-year history has been marked by a decline in consumer sentiment, though occasionally a short-lived decline doesn’t signal a downturn, said survey director Joanne Hsu.

“In general, people are not feeling good about the economy, and they’re not expecting things to get a whole lot better in the next year,” Prof. Hsu said. “How they’re feeling about the economy is very much colored by the fact that things have been not normal for what feels like a very long time.”

Mark Zandi, chief economist of Moody’s Analytics, cautions that consumer and business sentiment are so far gloomier than their actions would suggest. Although some consumers are cutting back spending on goods, it is being accompanied by increased spending on services, Mr. Zandi said. Hiring has remained strong and core business investment, excluding defense and transportation, has remained steady.

“There’s all kinds of disconnects in this economy, but there’s a very strong disconnect between how people say they feel and how they’re behaving,” Mr. Zandi said. “This gap between sentiment and behavior is the widest I’ve ever seen.”

Kraft Heinz CEO Miguel Patricio said that overall, prices for his company’s food and drinks are about 10% higher than a year ago. To soften the blow, Kraft Heinz is planning to offer more discounts, and it is working on some additions to its lineup that will appeal to cash-strapped consumers, such as its new $1 Lunchables and lower-priced packages of Kraft Singles cheese with fewer slices.

“You may decide not to buy a new pair of jeans or a new coffee machine, but you are going to bring food home,” Mr. Patricio said. “Instead of Rib-eye steaks, people are now doing more meatloaf or chicken parm for dinner.”

Walmart has warned that a steeper-than-expected pullback in shoppers’ spending would crimp its profit.

Photo: Alisha Jucevic for The Wall Street Journal

Write to Annie Gasparro at annie.gasparro@wsj.com and Theo Francis at theo.francis@wsj.com