The Bluebirds moved back into the play-off places with their first three-goal haul of the season.
Goals from Joe Ledley, Michael Chopra and Peter Whittingham secured victory and although ten-man Barnsley reduced the deficit through Jon Macken, City fully deserved the win.
There were three changes in the Cardiff line-up with Darcy Blake, Eddie Johnson, and Chopra all starting as City looked to recover from that defeat at Southampton.
They took the lead in the fourth minute from a Whittingham corner. The Barnsley defence stood still as the ball flew over and Ledley volleyed in from six yards.
Just after the half hour. Chopra struck a free-kick which keeper Heinz Muller stretched to push behind.
In the 41st minute, Michael Mifsud fired in a shot and took a slight deflection but Dimi Konstantopoulos leapt high to turn it over the bar.
With two minutes remaining in the first half, the Bluebirds doubled their lead when Muller spilled a long-range drive from Whittingham and Chopra fired the rebound across the keeper and into the far corner.
Mifsud went down in the area after a challenge from Roger Johnson, but referee Pat Miller showed no interest.
Even so the Tykes were beginning to look dangerous up front with Jamal Campbell-Ryce and Mifsud showing their pace.
Macken was brought on in the 62nd minute and with his first touch of the ball he lashed the ball home after the home defence failed to clear a towering Darren Moore header.
The visitors had Andranik Teymourian sent off in the 64th minute with a second yellow card for showing dissent when City won a free-kick.
The Bluebirds upped the pace and began passing the ball across the field and Gavin Rae smashed a shot against the crossbar as City looked for the killer third goal.
It finally came in the 89th minute from Whittingham, who cut in after Eddie Johnson slipped a pass out wide before curling a superb shot around the keeper and in off the far post.