Cobblers academy product Hornby, 17, has impressed since breaking into the first-team squad and has gone on to make 14 appearances for Aidy Boothroyd's side.
"Lewis deserves his new contract and we are delighted he will be with us for the next two-and-a-half years," boss Boothroyd told Northampton's official website.
"Just like Dean Snedker, he has made excellent progress and the challenge he has now is to continue to develop. He has already made a good number of appearances for a player so young.
"We are really pleased to have his future sorted out. This is another big pat on the back for our academy, who are producing some excellent young players.
"Young players know that by coming to Northampton Town not only will they receive excellent coaching, but there is a clear pathway through to our first-team squad."
- Sports & Recreation
- Aidy Boothroyd