Ricardo Vaz Te scored twice for the Tykes but it was not enough as goals from Angel Rangel, Danny Graham (2), and Nathan Dyer booked the Swans passage to the fourth round.
The result was only sealed when Graham scored in the 88th minute because the Tykes were pushing hard for an equaliser in the second half.
Vaz Te put Barnsley ahead in the 29th minute but the lead lasted less than a minute.
Rangel’ equalised for the Swans almost immediately, thanks to sloppy defending, and the Tykes were fortunate to be on level terms at the break
Apart from Vaz Te’s 29th minute goal,Keith’s Hill men had rarely threatened in the first 45 minutes while the Swans - who fielded a near full strength side - dominated possession and tested goalkeeper Luke Steele on a number of occasions.
Graham scored with a sensational 30 yard drive immediately after the break and when Dyer made it 3-1 soon after, the game looked all over for the Tykes.
But Vaz Te bundled the ball over the line from a Danny Drinkwater freekick to set up a tense final period and Barnsley were not out of the contest until Graham scored at the death.
Midfielder Drinkwater replaced Scott Wiseman in the only change to the side beaten at Doncaster Rovers last time out.
Swansea manager Brendan Rodgers rested only one player - goalkeeper Michael Vorm - which underlines the importance of the FA Cup to his club.
Vorm is replaced by Gerhard Tremmel. The Swans make one other enforced change with former Barnsley defender Garry Monk replacing Steven Caulker who is ineligible.
For the full report and reaction read Sports Monday, free inside the Yorkshire Post.