Williams will move to the Welsh club when the transfer window opens on January 1.
He is seen as a direct replacement for Ijah Anderson, who has been banned for six months after testing positive for cocaine.
Swans chairman Huw Jenkins said: "He is a player that Kenny (Jackett) has been watching for quite some time and we are delighted to finally clinch the deal to bring Tom to the Liberty Stadium."