Ginnelly, 24, spent last season on loan with the Tynecastle outfit and impressed sufficiently to land a permanent move.
He was released by PNE after reaching the end of his contract.
The move to Edinburgh reunites him with Joe Savage who was previously North End's head of recruitment. Savage is now Hearts' sporting director.
The best fans photos from Preston North End's 4-1 win over Huddersfield Town in the Carabao Cup.
Manchester United youngster being tested by Preston North End on a 'daily basis' after sparkling debut
Preston North End boss provides injury update on Manchester United loanee and addresses specualtion linking them to another Red Devils youngster
Player Ratings: Huddersfield Town 1-4 Preston North End - Carabao Cup win on the road
Wigan remain Championship relegation candidates but bookies' odds drift for Preston North End and Blackpool
Savage told Hearts' official website: "Josh is someone I know well and we’re really happy to get the deal done.
“He’s young, hungry and extremely talented, which is exactly the type of player we want pulling on the maroon jersey every week."
North End signed Ginnelly from Walsall for £75,000 in January 2019, seeing him as a player they could develop.
It didn't really happen for him at Deepdale, with him making only one start and eight substitute appearances in all competitions.
That single start was as a left-back in a Carabao Cup game against Hull City.
He was loaned to Bristol Rovers in January 2020, that a spell cut short when the Covid-19 pandemic saw the League One season curtailed.
Ginnelly joined Hearts on loan in September last year.
Injury restricted him to 10 appearances but he scored four goals - three of them in the Scottish Championship.
Hearts were promoted to the Scottish Premiership in May, so it will be top-flight football north of the border for Ginnelly.
Jam Tarts manager Robbie Neilson said: " ’m delighted to get Josh in permanently. He’s an explosive player, capable of providing a spark that can swing games in your favour.
"We saw glimpses of how good he was last season and now, with a full pre-season under his belt, he will hopefully go on to be a very important player for us."
Thanks for reading. If you value what we do and are able to support us, a digital subscription is just £1 per month for the first two months. Try us today by clicking here