After three years of turmoil that included the airing of his dark fantasies to the world, his conviction for conspiracy to commit kidnapping — and his subsequent release after 20 months when that charge was overturned — NYPD officer Gilberto Valle, better known as the “Cannibal Cop,” has triumphed in court for what appears to be a final time. The U.S. Court of Appeals for the 2nd Circuit affirmed a lower court’s acquittal of Valle on the conspiracy charge, and reversed a conviction on a charge of improperly accessing a government computer and obtaining information.

Fantasy crimes — even repellent, disgusting, unthinkable fantasy crimes worthy of universal condemnation — are not crimes, it said.

“This does not mean that fantasies are harmless,” Judge Barrington Parker wrote in an opinion. “To the contrary, fantasies of violence against women are both a symptom of and a contributor to a culture of exploitation, a massive social harm that demeans women. Yet we must not forget that in a free and functioning society, not every harm is meant to be addressed with the federal criminal law.”

In 2012, as his new wife and baby slept in the next room, Valle went online to discuss — repeatedly, at length, and in morbid detail — how great it would be to kidnap, murder and eat, among others, the mother of his child.

“The abduction will have to be flawless,” Gilberto Valle wrote of one victim in an Internet sex fetish community called “Dark Fetish Network.” “… I can make chloroform here.” He added: “She does look tasty, doesn’t she?” And: “I would want to see her suffer.”

After his wife alerted police when she found images of women who appeared to be dead on a laptop the couple shared, Valle wasn’t just fired and imprisoned. He became a tabloid sensation.

“Hungry for Love,” the New York Post front page crowed. A talk-show host dissected a dating profile Valle later created: “Cooking is one of his likes!”

In the HBO documentary “Thought Crimes,” produced earlier this year, a very calm, collected Valle — who said he’s no longer into fetish sites — tried to explain his gruesome online life.

“I try to explain it, it’s tough sometimes,” he said. “I guess the most important thing I got out of these chats, if I got anything out of them at all, was this acceptance.”

He added: “This is the first time I’m really opening up about all kinds of freaky stuff, cannibalism and bondage. All these years, this stuff is bottled up and here’s my chance to finally talk to somebody about it. It was such a relief to get it off my chest.”

But, Valle stressed, talking about something isn’t the same as doing it.

“When you’re typing it, you don’t really think about it,” he said. “You’re just sort of in the moment. But as soon as the computer went off, it’s over. I’m the person who I am. I’m incapable of any violence. I couldn’t hurt a fly.”

The jury that convicted Valle found this position dubious.

“We had a tome of the chats copied for us, and we were in the position to determine how much of it was real and how much of it was fantasy,” a juror whom HBO did not identify said. “… Any one of these women could have been a true victim of his.”

In a 2-to-1 ruling, the 2nd Circuit proved a more receptive audience.

“This is a case about the line between fantasy and criminal intent,” Parker wrote. “Although it is increasingly challenging to identify that line in the Internet age, it still exists and it must be rationally discernible in order to ensure that a person’s inclinations and fantasies are his own and beyond the reach of the government.”

The conspiracy charge could not stand in part, the court said, because the “real” and the “fantasy” chats “were indistinguishable.”

“The ‘real’ chats are replete with references to fantastical elements such as a human-sized oven, a spit, and a remote cabin in the woods, none of which Valle owned or made any effort to acquire,” the judge wrote. “The fantastical nature of the ‘real’ chats is bolstered by the entirely virtual nature of the alleged conspirators’ relationships.”

The computer charge hinged on the Computer Fraud and Abuse Act — a law some say offers unduly harsh penalties to people just because they used a computer to commit a crime. Valle objected to the government’s contention that he improperly accessed his computer; the court declined to decide this question, saying it had no clear answer, but invoked what is called “the rule of lenity,” which favors defendants in such ambiguous circumstances, and reversed the conviction.

[‘Beyond disgusting,’ says journalist Matthew Keys of his hacking conspiracy conviction]

The court also said it had to be careful — if it ruled against Valle on the computer charge, it might be giving the government a lot of power.

“While the Government might promise that it would not prosecute an individual for checking Facebook at work, we are not at liberty to take prosecutors at their word in such matters,” the opinion read. “A court should not uphold a highly problematic interpretation of a statute merely because the Government promises to use it responsibly.”

Judge Chester J. Straub dissented.

“This is not a case about governmental intrusion on one’s personal inclinations and fantasies,” he wrote, as the New York Times noted, “nor is it a case about governmental punishment of one’s thoughts. It is, instead, a jury’s determination of guilt for a conspiracy based on definitive conduct.”