In 2017, Sun competed at the World Championships. In the 200 metre freestyle, Sun won gold with a time of 1:44.39, setting a new Asian and Chinese national record. In the 400 metre freestyle, he won gold with a time of 3:41.38, finishing 2.47 seconds ahead of runner-up Mack Horton and winning his third straight 400 metre freestyle world title. Sun finished 5th in the 800 metre freestyle, failing to defend his title. He withdrew from the 1500 metre freestyle.