McGinn's previous deal still had two years to run but his good form has earned him an extended stay at Villa Park.
McGinn joined Aston Villa from Hibernian in the summer of 2018 and he has made 184 appearances in total, scoring 17 goals.
The Scotland international was named Aston Villa captain last summer by previous manager Steven Gerrard.
"Aston Villa is delighted to announce captain John McGinn has signed a new, long-term contract with the club," read a statement on Villa's official website.
"The midfielder's new deal will see him remain at Villa Park until 2027."
McGinn played 34 times in the Premier League and scored one last season as Aston Villa finished seventh to qualify for the Europa Conference League under Unai Emery.
'There's been plenty of ups and downs but I've loved every minute. We've been pretty successful and I think this season epitomised what everyone wants to achieve and shows the potential and ambition that everyone has,' McGinn told the club website.
'We are really starting to fulfil that with the manager and staff in place at the moment.
'If you told me when I was young you'd be playing every week in the Premier League against the best players in the world for a club like Aston Villa, it's just a pinch yourself moment. I'm loving it, don't take it for granted and just try every day to be the best that I can be.'