Tennis great Roger Federer has congratulated outgoing 23-time major winner Serena Williams on an "incredible career".

The 41-year-old Swiss revealed in a video message posted by the ATP Tour that he stayed up as a teenager to watch Williams' maiden US Open triumph in 1999 and lavished praise on her impact in the sport.

Williams, 40, last month announced her intention to evolve out of tennis after the US Open, where she has remarkably progressed to the third round following her upset win over second seed Anett Kontaveit on Thursday.

"I wanted to congratulate you for a most incredible career," 20-time grand slam champion Federer said.

"You know what you've achieved. I know what you've done. You know what it is, it just beyond incredible.

"I know it's probably with mixed feelings you're leaving this wonderful sport that has given you everything and more. I wish you all the best with your family."

Williams has won six US Open titles during her decorated playing career, including her maiden Flushing Meadows triumph in 1999.

"I think back at '99 at the US Open when you played Martina Hingis, I stayed up late to watch you battle it out as that was the beginning to your incredible career that you've had ever since," Federer said.

"I think the future is going to be wonderful for you. I'm sure it is. Please return to tennis. The tennis community and family will always welcome you with open arms and always be happy to see you again, so please return.

"For now enjoy this moment, enjoy the US Open, enjoy everything that's coming this next couple of weeks even though it might be hard for you.

"But I'm thinking of you and all my respect. I wish you all the very best for your future. Take care Serena."

Federer has not played professional tennis since Wimbledon last year, but has not retired and the former world number one is hoping for a return to action soon.