All the goals came in the second half with City taking the lead through Filip Kiss, Merthyr levelled with a goal from Matthew Harris.
Cardiff then went on to score three more with Jaye Bowen, Kadeem Harris and Etien Velikonja on the scoresheet.
City line up: Wilson, Amondarain, Owen, Kiss, Williams, Oshilaja, Bell, Wharton, Velikonja, Bowen, Harris.
Earlier this week the Development side lost 3 - 2 at QPR. That was a first league defeat since February. Rhys Healey scored both a Cardiff's goals.
Source: Cardiff City Online