Saints have announced the news on their official Twitter feed, making the 18-year-old the second of their players to pen a new deal on Friday.
Lloyd Isgrove earlier signed a one-year extension, but it is the renewal of Shaw which will please the club's fans all the more.
A breakthrough season last time out earned him many plaudits and a call-up to the Under-21 European Championship, although injury ruled him out.
He was linked with a move away as a result of his form, but the club celebrated Shaw's 18th birthday by announcing the deal with 29 first-team appearances already to his name.
"I'm very pleased to have finally signed it," Shaw told his club's official website tonight.
"I committed myself back in January, and I'm glad everything has been sorted out.
"I've been getting a lot of questions about my future, but all of the Saints fans will have known that I committed my future in January.
"I've been here since I was eight and I've loved every single moment of it. I want to stay at this club, and signing this contract means I'm here for another five years."
Like Shaw, Isgrove also broke through last season after making his debut in the Capital One Cup at Leeds.