Johnnie Jackson scored one and made another as Colchester comfortably won.
The midfielder put the visitors ahead in the 32nd minute when a long ball from keeper Dean Gerken was nodded down by Clive Platt, and Jackson struck with a left-foot shot from the edge of the area.
Jackson turned provider in the 44th minute with a pass which allowed Scott Vernon to score from close range.
Swindon pulled a goal back with a 68th-minute penalty after Colchester defender Matt Heath was adjudged to have handled, allowing Simon Cox to notch his third goal of the season.
Swindon staged a late rally which almost earned them a point, Billy Paynter heading against the underside of the bar and Cox's effort from the rebound being pushed to safety by Gerken.
But Colchester secured the win in the last minute when Mark Yeates put Sunday-Akanni Wasiu clear and he netted his shot.