It was the tea party the Obamas just couldn’t resist.

A White House “Alice in Wonderland” costume ball — put on by Johnny Depp and Hollywood director Tim Burton — proved to be a Mad-as-a-Hatter idea that was never made public for fear of a political backlash during hard economic times, according to a new tell-all.

“The Obamas,” by New York Times correspondent Jodi Kantor, tells of the first Halloween party the first couple feted at the White House in 2009. It was so over the top that “Star Wars” creator George Lucas sent the original Chewbacca to mingle with invited guests.

The book reveals how any official announcement of the glittering affair — coming at a time when Tea Party activists and voters furious over the lagging economy, 10-percent unemployment rate, bank bailouts and Obama’s health-care plan were staging protests — quickly vanished down the rabbit hole.

“White House officials were so nervous about how a splashy, Hollywood-esque party would look to jobless Americans — or their representatives in Congress, who would soon vote on health care — that the event was not discussed publicly and Burton’s and Depp’s contributions went unacknowledged,” the book says.

However, the White House made certain that more humble Halloween festivities earlier that day — for thousands of Washington-area schoolkids — were well reported by the press corps.

Then the Obamas went inside, where an invitation-only affair for children of military personnel and White House administrators unfolded in the East Room.

Unbeknownst to reporters, the State Dining Room had also been transformed into a secretive White House Wonderland.

Tim Burton decorated it “in his signature creepy-comic style. His film version was about to be released, and he had turned the room into the Mad Hatter’s tea party, with a long table set with antique-looking linens, enormous stuffed animals in chairs, and tiered serving plates with treats like bone-shaped meringue cookies,” reports the book, which The Post purchased at a Manhattan bookstore.

“Fruit punch was served in blood vials at the bar. Burton’s own Mad Hatter, the actor Johnny Depp, presided over the scene in full costume, standing up on a table to welcome everyone in character.”

The Obamas’ daughters, Malia and Sasha, then 11 and 8 respectively, “sat at the table, surrounded by a gaggle of their friends, and then proceeded to the next delight, a magic show in the East Room.”

Kantor’s book details more personal aspects of the Obama White House, serving up glimpses of the first couple’s marriage, parenting, sometimes tense handling of staff issues and even the president’s sly sense of humor when it comes to race.

One morning during his Senate campaign, Obama didn’t show up to a meeting with donors. “After a frantic search, a white staffer named Peter Coffey called Obama’s barbershop to find that, yes, he was there.”

The president confronted Coffey about the call later that day.

“ ‘The relationship between a black man and his barber is sacred,’ Obama bellowed . . . ‘For failing to understand this truth, your punishment is to watch the movie “Barbershop.” And for further punishment, you will then watch the sequel, “Barbershop 2.” ’ ”

Often White House staffers found themselves in the middle of husband-and-wife quarrels.

“The advisors could feel hopelessly caught between husband and wife,” Kantor writes. “The Obama marriage was awkward for everyone: for the aides, for the president . . . and for the first lady.”