A fed-up federal judge banned Roger Stone from posting on social media for allegedly repeatedly violating a gag order in his case.

DC Judge Amy Berman Jackson said she wouldn’t toss President Trump’s former adviser in jail for violating her order, saying that holding a contempt hearing would only generate more media buzz that could sway potential jurors.

“I’ve twice given you the benefit of the doubt. Your lawyer had to … twist himself into a pretzel to argue that these posts didn’t cross the line,” the judge slammed Stone, according to CNN. “The goal has been to draw maximum attention.”

Berman issued the gag order in February after the outspoken Republican operative posted a photo of the judge with cross hairs next to her head.

Prosecutors said Stone violated the judge’s order by repeatedly discussing his case on Instagram.

Berman said dealing with Stone was like “wrestling with behavior that has more to do with middle school than a court of law.”

It took an hour for her to painstakingly read each and every one of the self-styled “dirty trickster’s” posts aloud, asking his attorney Bruce Rogow if they violated her gag order.

Rogow said he didn’t believe the posts were in violation — adding, “I’m sorry the court is offended by these things.”

But Berman felt otherwise, issuing the ban after a one-hour break.

Stone is accused of lying to House Intelligence Committee investigators probing Russian interference in the 2016 presidential election and witness tampering. His trial is slated for November.

With Post wires