The 25-year-old has signed a two-year contract with the Kent club, after being given a free transfer by the Tykes.
Williams began his career at West Ham United, but failed to make an appearance for the club before joining Barnsley.
The move includes a sell-on clause should Williams command a transfer fee when he leaves Priestfield.