The present American moment is a frightening one, where crowds of protesters, egged on by the mainstream media, are not only protesting what they see as racial injustice, but attempting to overturn our entire political and economic system.

In so doing, they demand that everyone confirm to their whims and repeat their mantras, on pain of being “canceled” or shunted to the margins of society.

It seems scary, and it is, but the good news is that it was all predicted 200 years ago.

The French philosopher Alexis de Tocqueville wrote Democracy in America after traveling extensively in the United States in the heyday of our republic. He came away with a profound appreciation for the ideas, habits, and institutions that made American democracy work.

But he also diagnosed the risks and flaws of our grand experiment. He foresaw not only that slavery and racism would lead to conflict, but also that freedom of thought would often be in danger.

Tocqueville noted that the power of the majority — not just politically, but also socially — at the heart of democracy could become a form of tyranny greater than the most ruthless despotism in European monarchy.

While a king’s power was “physical only,” Tocqueville noted, a democratic majority could control thought itself.

“I know no country in which, speaking generally, there is less independence of mind and true freedom of discussion than in America,” he wrote.

That was two centuries ago — before newspapers had a national reach, before there was any idea of “social media,” before there were “woke” mobs.

America was always susceptible to the power of conformity because our love of equality causes us to regard distinction with suspicion. “When everything is more or less level,” he observed, “the slightest variation is noticed.” Hence, Tocqueville said, there was a “strange melancholy … in the midst of abundance.”

He explained: “In America the majority has enclosed thought within a formidable fence. A writer is free inside that area, but woe to the man who goes beyond it. … The master no longer says: ‘Think like me or you die.’ He does say: ‘You are free not to think as I do; you can keep your life and property and all; but from this day you are a stranger among us.'”

It is as if Tocqueville anticipated the “shadow-banning” of Twitter and the abuses of “cancel culture,” two centuries ago.

Tocqueville even predicted Americans would condemn him: “If these lines ever come to be read in America, I am sure of two things; first, that all readers will raise their voices to condemn me; secondly, that in the depths of their conscience many will hold me innocent.”

We are living in a time when the divergence between what people say in public and what people believe in private has become particularly stark — where you must mouth the mantra, or condemn yourself.

But Tocqueville also provided a remedy: “I know only one way of preventing men from degrading themselves, namely, not to give anybody that omnipotence which carries with it sovereign power to debase them.”

The antidote to the power of conformity would be little islands of independence: alternative newspapers, for instance; or the legal fraternity, a kind of natural aristocracy; or the existence of a large middle class that would defend its property and interests against abuse.

All of those institutions are under attack. The mainstream media and tech giants are trying to crush competition. The law firms are mostly on the left. And the middle class is reeling from economic shock.

Yet we still have alternative media, we have the Federalist Society, and we have a few civil libertarians still willing to stand up to the “deep state.” And the middle class is eager to return to work, to innovate and grow.

We can get through this. Even Tocqueville thought we would.

Joel B. Pollak is Senior Editor-at-Large at Breitbart News and the host of Breitbart News Sunday on Sirius XM Patriot on Sunday evenings from 7 p.m. to 10 p.m. ET (4 p.m. to 7 p.m. PT). His new book, RED NOVEMBER, is available for pre-order. He is a winner of the 2018 Robert Novak Journalism Alumni Fellowship. Follow him on Twitter at @joelpollak.