A dirty NYPD cop admitted Tuesday to taking bribes and ferrying cocaine for an informant posing as a drug dealer in exchange for six years in prison.

Johnny Diaz, 48, wearing an orange prison-issue jumpsuit, took the plea deal in Manhattan Supreme Court before Justice James Burke.

“Are you pleading guilty to these crimes because you are in fact guilty?” the judge asked.

“Yes,” Diaz, a 23-year NYPD veteran, replied softly.

He was arrested in June for a slew of misdeeds uncovered during an internal probe.

“The particular acts he committed — pocketing seized cash, accepting a bribe, and helping to transport cocaine — each undermined public safety in their own right,” said Manhattan District Attorney Cyrus Vance Jr. in a statement.

“But more dangerously, his pattern of corruption jeopardized New Yorkers’ faith in law enforcement at a time when police and prosecutors are working proactively every day to increase public confidence in our work,” Vance said.

On May 23, Diaz arrested an undercover investigator posing as a drug dealer and failed to log $1,000 in cash he recovered from the man, according to prosecutors.

Then the crooked cop built a rapport with the informant and offered to throw his pending case in exchange for $20,000, court papers charge.

The father of two entered into another illicit business venture with the dealer and, on June 15, helped him transport a kilo of cocaine in exchange for $4,000. He admitted to the informant, “I should know better — I’m a cop.”

Defense lawyer Patrick Brackley said, “This is a good man from a good family that will now put this behind him and get on with his life.”

It’s unclear whether Diaz will lose his pension.