City residents pay more for everything from a gallon of gas to the rent on their apartments, thanks to the area’s packed-to-the-gills real estate, shifting demographics and sky-high taxes, experts said.

Nearly half admitted in a recent poll that they can’t afford to live anywhere in the state and might be forced to seek greener economic pastures elsewhere — and public policy experts say it’s a confluence of factors that’s the root cause.

“It’s all about the location,” said Sewin Chan, an economist and associate professor of public policy at NYU. “If the land and the property values are higher in Manhattan, a gallon of milk is just going to cost more here than in the middle of the country.”

That’s because the higher the rent for your local bodega, the higher the return they need to make ends meet, Chan explained.

That simple math bears out in New Yorkers paying $4.43 for a gallon of milk, or 42 percent more than the national average; $3.46 for a loaf of bread, which is 47 percent more; and $3.55 for a dozen eggs, or 55 percent more.

“Part of what you’re buying is not just the gallon of milk, it’s the storage, the retail facility it’s going to be in,” Chan said.

The same principle extends to residential space, where the available housing stock can’t keep pace with demand from increasingly affluent job-hunters flocking from other states — to the detriment of longtime New Yorkers, Chan said.

“With a city like New York, it’s mostly going to be demand-driven,” she said. “There’s not a lot of new supply, and people want to live in New York.”

That demand is driving up rent — and driving out lower-income residents in droves.

Also in play are prohibitive taxes, said E.J. McMahon, a researcher at the Empire Center for Public Policy.

“The property tax is a major portion of the rent tenants pay,” said McMahon. “The sales tax is high. It all drives up the cost of living.”

Heavy taxes also run up prices at the pump, where New Yorkers pay $3.05 per gallon, or 12.5 percent more than the national average.

Of that $3.05, more than 44 cents goes toward state taxes and fees — the fifth-highest amount of any state, and nearly 11 cents more than the national average, according to American Petroleum Institute statistics current as of Jan. 1.

Squeezed out by fierce competition for a largely static amount of space, more and more New Yorkers are thinking about moving somewhere more affordable.

But still, “people want to live in New York,” Chan said. “This is not going away.”