Executives of social media groups like Twitter and Facebook also risk individual fines up to five million euros in case of non-compliance, said the government in a statement.
"Hate crimes that are not effectively combatted and prosecuted pose a great danger for the peaceful cohesion of a free, open and democratic society," said Chancellor Angela Merkel's cabinet.
Since the arrival of around one million asylum seekers in Germany since 2015, the volume of xenophobic hate speech has exploded online.
But Merkel's government decided on the tough action after determining that social network giants were not doing enough to erase content that ran afoul of German law.
More From This Section
Beyond hate speech and fake news, the draft legislation also covers other illegal content, including child pornography and terror-related activity.
The companies would have 24 hours to remove any posts that openly flout German law after they are flagged by users.
Other offensive content would have to be deleted within seven days after it is reported.
The government said it was pushed into action as "there is currently a massive change in the online discussion".
"The culture of online debate is often aggressive, hurtful and hate-filled," it noted.
"Through hate crimes, anyone can be defamed because of his or her opinion, skin colour or origin, religion, gender or sexual orientation."
The draft law stills require approval from parliament, which is dominated by Merkel's grand right-left coalition.