How many texts and emails to your ex is too many? This judge says 5,026.

A divorce judge has ruled that Queens dad Daniel Meredith fired off far too many messages when he sent that number to his estranged wife in that span of a year — calling it “harassment.”

“This has to stop,” said Queens Supreme Court Justice Margaret Parisi McGowan said in June, before threatening to toss him in jail if he continued to blow up his ex’s phone, transcripts show.

“This is beyond, beyond a normal communication.”

The judge slapped Meredith with a temporary order of protection, declaring the 14-per-day average to his wife Donna “out of proportion” and placing him on a strict diet of one-text-a-day — while allowing him to speak to his kids via FaceTime once a night between 6:15 and 6:30 p.m.

But Meredith, a 42-year-old an artist for an architectural firm protested in court documents that nearly all of the past year’s back-and-forths were about the couple’s three toddler-aged kids, the family car and their apartment in Sunnyside.

Now, the dad — who has been locked in a divorce battle with his 35-year-old marketing producer wife since January — says he can’t communicate with their nanny or daycare, and is fighting to stop the judge from making the limits permanent, court documents show.

He insists he only sent his wife an average of eight texts a day over the past year, while she sent him an average of six — which is far lower than the average person their age.

“According to Internet research and articles I found online … the average American sends and receives 94 test messages per day and the average American between the ages of 35 and 44 sends and receives 52 text messages per day,” he said in court papers he filed to fight the restraining order.

“Americans in our age group regularly text message each other at the rate of 52 text messages a day.”

The couple has since filed hundreds of pages of court documents in which they quibble over how many texts and emails were sent and the content of the messages.

They note daily texting averages down to two decimal points — and how many were “initiating” as opposed to “responding” messages.

“The number of texts I sent on our shared text thread with our nanny since last year is far less than the number of texts our nanny has sent me/us,” Meredith argues at one point in the paperwork.

He also insists that, in many of his daily texts, he was simply giving a quick response to photos and videos of the kids that were sent to him by the nanny on a text chain with the wife.

Meredith and his lawyer, Susanne Kimberly Bracker, declined comment. Donna and her attorney, Mia Poppe, also declined.

A court date has not yet been set for the couple’s next hearing.