The 52-year-old took the reins at the Swans in 2011 and has led them to 10 finals appearances in that time, missing the top eight only twice.
He has reached four grand finals in that time, including last year's defeat to Geelong, and guided the Swans to the 2012 flag.
Longmire also helped deliver Sydney's drought-breaking 2005 premiership as an assistant to Paul Roos and is the Swans' all-time coaching games record holder.
He has coached 283 games at a winning ratio of 63 per cent, and will break the 300-game barrier this season.
"It's a privilege to continue to be the coach of this great club," Longmire said in a club statement.
"I'm lucky to have great people around me, great staff and a fantastic young playing group.
"It's exciting to work with young players on their way through to help them learn and grow, while I'm also fortunate to work with quality leaders who take pride in passing on their own experience."
Sydney will be out to go one better in 2023 after being smashed by the Cats in last year's premiership decider.
The upcoming season is likely to be legendary forward Lance Franklin's last as a player, but the Swans appear well set up for future success under Longmire.
"Everyone at our club is excited, not only about the 2023 season ahead, but about the journey we're on and the opportunity we have before us," Longmire said.
"We're committed to getting better every day."
Sydney chief executive Tom Harley said the club is delighted with Longmire's ongoing commitment.
"John has been a fantastic leader of our football club for a very long time and we are pleased he will continue in his role for at least a few more seasons," Harley said.
"We believe we have a strong young list and John has a unique ability to form relationships with our players, which is particularly important with our emerging group."