Australian swimmer Mack Horton, a fierce anti-doping campaigner, called time on his career on Sunday just months ahead of the Paris Olympics.

The 27-year-old, who famously refused to stand on the podium alongside China's Sun Yang at the 2019 world championships, said the passion had left him.

"I dearly wanted to swim in Paris but the hunger wasn't there," he said in a statement.

"I always want to give my all and I am not someone who just wants to make up the numbers, so this is the right time to step away."

Horton won gold in the 400-meter freestyle at the 2016 Rio Olympics ahead of Sun as well as titles at the world championships and Commonwealth Games.

But he is best remembered for the 400 silver he won at the 2019 worlds in South Korea.

Horton refused to shake the Chinese athlete's hand or even stand on the podium alongside him, reigniting a row from Rio, where he labelled Sun a "drug cheat."

Three-time Olympic champion Sun was subsequently slapped with an eight-year ban after refusing to give samples during a surprise doping test.

It was later reduced on appeal to the Court of Arbitration for Sport.

While Horton's stance won widespread support within the swimming community, it provoked a furious reaction in China, with his Instagram account trolled, some even posting death threats.

"I don't have any regrets ... only that the years went so quickly," Horton said.