President Ramaphosa announced several other measures, including the closure of schools from Wednesday and the banning of all gatherings of more than 100 people in an effort to curb the spread of the coronavirus.
The president also declared Covid-19 outbreak a national state of disaster.
South Africa's government on Sunday imposed travel restrictions after confirming 61 cases of the Covid-19 infection in the country.
The strict travel ban on foreigners from high-risk countries will come into effect Wednesday.
“We have cancelled visas and previously granted visas are revoked,” President Cyril Ramaphosa said on Sunday night.
The countries include Italy, Iran, South Korea, Spain, Germany, the US, the UK and China.
President Ramaphosa announced several other measures, including the closure of schools from Wednesday and the banning of all gatherings of more than 100 people in an effort to curb the spread of the coronavirus.
Schools will be closed from March 18 and will remain closed “until after the Easter weekend”.
The South African leader told the nation that the number of coronavirus cases was “expected to rise in the coming days and weeks”.
“Initially it was people who had travelled outside the country, especially Italy. It is concerning now that we are dealing with internal transmission of the virus,” he said.
Next week's Human Rights Day celebrations, a massive event in the South African calendar, has also been suspended.
President Ramaphosa also discouraged travel to high-risk countries and non-essential domestic travel.
“Never before in the history of our democracy has our country been confronted with such a severe situation,” he said.
The president also declared Covid-19 outbreak a national state of disaster in relation to the Disaster Management Act.
“This will enable us to have an integrated and coordinated disaster management mechanism that will focus on preventing and reducing the outbreak of this virus. We will also be able to set up emergency rapid and effective response systems to mitigate the severity of its impact,” President Ramaphosa explained.