The South African all-rounder returned 1-21 from seven overs, dismissing Miles Hammond for 18 as Gloucestershire were bowled out for 235 in 49 overs. De Swardt then scored 42 from 53 balls during the chase, adding 55 with Ben Cox to take the Foxes from 136-5 to 191-6.
On this day: Test cricket enters review era
His composed innings, with two fours, helped keep Leicestershire on course before Ajaz Patel sealed victory with 10 balls remaining.
Graeme van Buuren had a mixed outing for Gloucestershire. The South African-born all-rounder managed five from 17 balls but responded with 2-43 from his 10 overs. He removed Jonny Tattersall for 17 and Ben Green for one, briefly giving Gloucestershire hope in a close finish.
ALSO: CSA celebrates record-breaking digital season
Elsewhere, Glamorgan recovered from 54-5 to beat Sussex by 12 runs at Neath. Jack Hope-Bell and Alex Horton struck 123 and 122 respectively, sharing a 240-run sixth-wicket stand as Glamorgan reached 295-8. Sussex finished on 283-8 despite three half-centuries. Dan Douthwaite claimed 4-54 to finish the job.
Photo: Leicestershire County Cricket Club/X