These weren’t violent confrontations that spun out of control: All but one were shot while sitting in their patrol cars. The other was gunned down and killed in an ambush outside police headquarters.

As William McManus, chief of police in San Antonio — where Detective Benjamin Marconi, a father of three, was killed in cold blood — said: “The uniform was targeted.”

And these are just the latest in a growing list of targeted attacks. Two other cops were shot and killed this month while sitting in their patrol cars in a suburb of Cedar Rapids, Iowa. In June, a man armed with two rifles and a pistol killed three officers near a gas station in Baton Rouge, La.

And just 10 days before that, five Dallas cops working a protest against police shootings were themselves killed by a gunman. That was the single deadliest day for US law enforcement since 9/11.

It’s a series of entirely separate attacks, yet there’s a connection: All come in the wake of two years of incendiary rhetoric directed against police officers, a drumbeat of denunciation of cops as a band of racist murderers.

So far this year, 58 cops have died in the line of duty — well ahead of the 41 total in 2015.

All those ranting about how over-the-top rhetoric on social media threatens our democracy should consider how anti-police rhetoric from politicians and the news media has helped take the lives of those sworn to keep Americans safe.

And when police officers doing their duty aren’t safe, then no one is.