O'Sullivan made just three appearances for Cardiff's first team after coming through the club's academy system.
The 22-year-old had two loan spells with Newport last season, scoring one goal in 22 games.
He is the second Cardiff player to join Colchester this month, following the arrival of striker Eli Phipps.
"I had a chat with the manager at Cardiff and there wasn't a way through for me there," he told BBC Essex.
"I'm here to play first team football as anything else would be a backwards step.
"I was on loan at Newport last season and what is there compared to the facilities here is much better with the training ground and the stadium"
Find all the latest football transfers on our dedicated page or visit our Premier League tracker here.
League Two side Colchester United have signed Cardiff City midfielder Tommy O'Sullivan for an undisclosed fee on a deal until June 2018.