The 24-year-old forward, who was a restricted free agent, avoided a salary arbitration hearing scheduled for July 31.
"Especially to do the four years and for them to have that confidence in me is really exciting," Compher said. "I love Denver, I love the team and the fans there, so I'm really excited about it."
Compher had NHL career highs in goals (16), assists (16) and points (32) in 66 games with the Avalanche last season and six points (four goals, two assists) in 12 Stanley Cup Playoff games.
RELATED: [NHL Free Agent Tracker\]
"J.T. has been one of our most versatile forwards over the past two years," Avalanche general manager Joe Sakic said. "He plays on our power play, kills penalties and has played up and down our lineup. He has scored some big goals late in games and we are counting on him to have an even more expanded role moving forward. We are excited to have him under contract for the next four seasons."
Of his versatility, Compher said, "I think each year I've taken a step forward and I've been put in a lot of different situations since I've been there. And I'm just trying to take advantage of each different part of the game they use me in, and do whatever the team needs, play on whatever line, or the power play, penalty kill, whatever it is."
Selected by the Buffalo Sabres in the second round (No. 35) of the 2013 NHL Draft, Compher has 60 points (32 goals, 28 assists) in 156 regular-season games, all with the Avalanche, and nine points (four goals, five assists) in 18 playoff games.
NHL.com staff writer Tracey Myers contributed to this report