The 20-year-old, who featured for the Tykes against Everton in the League Cup last week, moves to Oakwell on a three-year deal for an undisclosed fee.
The youngster, who is a Birmingham City academy product, previously had loan spells at Oxford City and Lincoln City.
Speaking to the club's website, Townsend said: "I'm delighted to get the deal done. Since day one I've really enjoyed training and everything about being here. All the lads made me feel welcome and it's just the right idea to join permanently.
"There's great competition between me and Adam and we'll be fighting it out which will make both of us better."
Townsend could feature for Barnsley against Scunthorpe United in the Johnstone's Paint Trophy tonight.