Locked up in a federal prison cell with nobody left to lie to, serial conman John Thomas is kidding himself.

That seemed to be the verdict of U.S. District Judge James Zagel, who on Tuesday rejected the 52-year-old former federal mole’s bizarre bid for freedom, saying the fraudster is “impossible to trust.”

Thomas, a smooth-talking felon, has been locked up since May after he pleaded guilty to looting $370,000 of tax increment financing funds that the Village of Riverdale handed him in 2012 to fix the south suburb’s blighted marina.

Last month, he made a desperate plea to be released, writing in a self-penned legal filing that only he could clean up the mess he made of the marina, from where hundreds of thousands of dollars worth of boats and equipment were also stolen on his watch.

But Zagel on Tuesday told Thomas he’d “failed pretty spectacularly” to behave himself when he was previously released on house arrest — a wild, two-week stint during which he allegedly arranged a secret tryst with his lover, a key witness against him, then tried to rope his dentist into the cover story.

Thomas’s past transgressions mean its “impossible to trust him to keep his word,” Zagel said. He added, “I’m willing to concede that as he stands here today, he believes he can — but he won’t.”

Thomas, who faces up to 20 years behind bars, had argued that if released, he could arrange to transfer the marina to the ownership of the Cook County Forest Preserve, so that taxpayers could recoup some of their losses and repairs could be made.

He had to be shushed by one of his attorneys, Joe “The Shark” Lopez, as he frantically tried to convince Zagel.

Another of Thomas’s attorneys, Larry Beaumont, argued that Thomas is “a very different person now than he was” when he was locked up 10 weeks ago, noting that Thomas had lost a lot of weight, stopped drinking, and now understands the seriousness of being in custody.

But Thomas’s sentencing was delayed until September 29, so that a court-appointed psychologist can determine whether he is mentally ill.

Convicted of a billboard scam in the 1990s in New York, Thomas previously dodged prison by becoming a mole for the government, wearing a wire for the FBI and boasting that he was “untouchable,” sources say.

Speaking outside court Tuesday, Lopez, described Thomas as a “kleptomaniac” who “cannot help himself.”

“He’s making an honest attempt at making restitution,” Beaumont added.