The 29-year-old England youth international joins the Cobblers following one season with the Robins, during which he scored six goals in 34 League Two appearances.
"Darren's pedigree is clear for everyone to see," manager Aidy Boothroyd told the club's official website.
"I think we've got a really, really good player on our hands, he's got a great record and he's in absolutely fantastic shape. He has had a lot of other offers so I'm delighted we've managed to get him.
"He's a terrific professional, he scores goals from midfield and he's a winner. He has played a lot of football in the top two divisions, he is a good age and I think he will be another excellent addition to our squad."
Carter has previously played in the Premier League with Sunderland and West Midlands duo West Bromwich Albion and Birmingham City.