Conservative commentators have hit out at former US President Barack Obama after he evoked Nazi Germany in a bid to encourage voters to remain vigilant and protect democracy.

"We get complacent and assume that things continue as they have been, just automatically, and they don't," Obama said in comments to the Economic Club of Chicago earlier this week. Videos of the event were shared on social media.

"You have to tend to this garden of democracy — otherwise, things can fall apart fairly quickly. And we've seen societies where that happens," he added, referring to the late 1920 and 1930s.

Read more: The racist comments of Donald Trump

"Now, presume there was a ballroom here in Vienna in the late 1920s or 30s that looked pretty sophisticated and seemed as if it, filled with the music and art and literature and science that was emerging, would continue into perpetuity," Obama said.

"And then 60 million people died. An entire world was plunged into chaos. So you've got to pay attention and vote." About 60 million people died in World War II.

Images of the speech were shared on Twitter by some of the 1,800 attendees — mostly business leaders in the Chicago area.

Conservatives angry

Read more: What are the links between US and German neo-Nazis?

Conservative commentators seized on the comments as inappropriately comparing current US President Donald Trump to the mass-murdering fascist Adolf Hitler. Obama never mentioned Trump or Hitler by name.

Fox News commentator Jesse Watters said the comparison was "horrible."

"I thought Obama was better than this. To compare his successor to Adolf Hitler. Horrible. Horrible. Just demeaning. Beneath him," he said in a discussion on The Five talk show.

Fellow Fox News conservative Greg Gutfeld was similarly upset by the comments.

"He said this just hours before Trump recognized Jerusalem as Israel's capital, which makes Donald Trump a pretty weak Nazi. And after America had just decimated ISIS, the worst group of fascists since the Nazis. So we aren't becoming Nazis. We're stopping Nazis. But this is what liberals do, comparing adversaries to Hitler."

Conservative commentator and former game show host Chuck Woolery, who himself has been accused of having anti-Semitic views, said Obama's comments were "despicable."