The 52-year-old took the reins at the Swans in 2011 and has led them to 10 finals appearances, 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."
Longmire played 200 games for North Melbourne and kicked 511 goals, retiring as a player after the Kangaroos' 1999 premiership and joining Sydney as an assistant coach in 2002.
Swans 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."
Meanwhile, Sydney co-captain Callum Mills (finger) and gun forward Tom Papley (ribs) will both miss Friday's practice match against Carlton through injury.
The important pair will return for the round-one meeting with Gold Coast on March 18, but teammates Tom Hickey (calf), Robbie Fox (calf) and Ryan Clarke (hamstring) have all been ruled out.
Hickey and Clarke will both miss multiple games early in the season.