Convicted swindler Martin Shkreli was decreed a “danger to society” Wednesday and jailed by a federal judge following Facebook posts in which the loudmouth former drug company exec put a bounty out on Hillary Clinton’s hair.

Despite a groveling letter from the 34-year-old claiming the social media offering of $5,000 for a strand of the former secretary of state’s hair was an “awkward attempt at humor or satire,” Brooklyn federal court judge Kiyo Matsumoto revoked his $5 million bond and ordered him thrown behind bars.

“What’s so funny about that?” the seething judge, so angry she could barely speak, asked defense attorney Ben Brafman as a deflated Shkreli sat beside him, elbows on the defense table.

“One ongoing concern of mine is that he has been touted as a brilliant young man, the mind of his generation, yet he lacks the ability to understand what’s appropriate,” Matsumoto said of Shkreli, before deeming him a threat to the community.

The creepy Clinton posting, the climax of a series of other Facebook rants in which Shkreli seemed to suggest he intended to clone the failed Democratic presidential candidate, was scrubbed from his account after the Secret Service contacted him.

“On HRC’s book tour, try and grab a hair from her,” he wrote on Sept. 4. “I must confirm the sequences I have. Will pay $5,000 per hair obtained from Hillary Clinton.”

Judge Matsumoto also cited testimony in which a witness at Shkreli’s Ponzi scheme trial described him as being like the “Pied Piper.” The judge said that caused her to worry what any one of his 70,000 Facebook followers might do after such an inflammatory call to action.

Brafman continued to beg Matsumoto to reconsider throwing his client behind bars until his sentencing next year for the Ponzi scheme, saying “Judge, we’ll do anything you ask.”

But the jurist wasn’t buying it, and ordered the marshals to take the normally wisecracking so-called Pharma Bro into custody.

A suddenly pale Shkreli slipped a piece of paper in his briefcase before glancing at his attorneys. Then he followed the marshals out of the courtroom.

It was a far cry from his boasts to The Post in January, “I kind of think it would be exciting, you know, to spend six months or a year in prison.”

Prosecutor Jacquelyn Kasulis laughed off the defense’s attempts to change the judge’s mind.

“He can’t control Mr. Shkreli, that is very clear,” Kasulis insisted, gesturing to Brafman. “[Shkreli’s] demonstrated an escalating pattern of threats against women.

“He’s not special, by any stretch of the imagination,” she added. “He’s a convicted felon.”

In a Sept. 12 letter to Matsumoto, Shkreli apologized for the Clinton threat, which he called an “awkward attempt at humor or satire,” saying he never intended to “threaten” the former first lady.

Shkreli was convicted of defrauding hedge fund investors in early August, and faces up to 20 years behind bars when sentenced.

In the hours after jurors returned the mixed verdict, he announced on a Facebook livestream that prison — which he called “Club Fed” — wouldn’t be that bad.

“I’ll play basketball and tennis and Xbox,” he mused.

Shkreli will now languish in a maximum security federal jail in Brooklyn’s Sunset Park until at least his sentencing on Jan. 16, 2018 after which he could be transferred to another facility.

“F— the government,” Shkreli wrote on Facebook after prosecutors filed a motion asking the judge to revoke his hefty bond. “I will never kiss their ring or snitch. Come at me with your hardest because I haven’t seen anything impressive yet.”

“We are obviously disappointed, and believed the court arrived at the wrong decision, but she’s the judge,” Brafman said as the legal team left court with Shkreli’s distraught-looking father.

Shkreli rose to notoriety after purchasing the sole copy of the Wu-tang Clan album “Once Upon a Time in Shaolin” at auction in 2015 for $2 million, deciding he would keep it for only himself to hear before recently deciding to auction it off.

Later that year, he earned the moniker of “Most Hated Man in America” for jacking up the price of life-saving drug Daraprim 5,000 percent.