It’s the icing on the cake for cupcake addicts.

A 24-hour cupcake-dispensing “ATM’’ is set to open on the Upper East Side on Tuesday, giving New Yorkers the basic convenience of being able to buy fresh, gourmet goodies with the push of a button anytime they want.

“The cupcakes are as fresh as they are at the store,” crowed Charles Nelson, 44, who along with his wife founded Sprinkles Cupcakes.

The pink cupcake automat is located next to the Nelsons’ Sprinkles Cupcakes bakery on Lexington Avenue between 60th and 61st.

The Beverly Hills-based company has already opened cupcake ATMs in LA, Chicago, Atlanta and Dallas.

The machine can dispense up to 20 varieties by way of a touch screen that works just like a bank ATM: You make your selection, swipe your credit card, and out comes your treat in a brown and pink box.

Each cupcake costs $4.25. Flavors include red velvet, Cuban coffee, banana dark chocolate and cinnamon sugar.

There is even an offering for dogs: two mini-cupcakes for $5. They come in one flavor, are sugar-free and have a yogurt frosting.

The machine will be able to hold 760 cupcakes at a time and will be restocked two to three times a day to keep things fresh, Nelson said.

Nelson said he got the idea for the foodie ATM six years ago, when his wife, Candace, 39, was pregnant with their first child.

“It was the middle of the night, and my wife really wanted a cupcake,” he said. “I own a cupcake shop and couldn’t even get a cupcake!”