The 31-year-old is back at his first club on an 18-month contract after Liverpool sanctioned his departure at the end of an unsuccessful two-and-a-half-year spell.
Cole, who started 108 league games for West Ham during his first period at the club, will wear the No 26 shirt he gave up to join Chelsea in 2003.
He told the club's official website: "It is a great move for me. Coming back here brings back all the memories of the pitches I learnt how to play on.
"This is where I learnt my trade and I'm happy to have another chance to be here. I've always loved West Ham and I hope I can give the club a few memorable seasons.
"The timing was right for me to come back and I'm happy. I'm back in London and I'm delighted to be here. I want to be here and I want to make an impact.
"Sam Allardyce didn't have to sell me the club for me to come back. For me, I have had 18 months at Liverpool where I haven't played much football and Sam wants to play me.
"I feel like I owe the club a little bit as well because if it wasn't for West Ham I wouldn't be a footballer. This club's great youth-team coaches taught me the trade."
Cole could also have moved to QPR, and been reunited with his former West Ham boss Harry Redknapp.
He said: "That was the hardest thing for me, because Harry gave me my first chance and I will be forever indebted to him, but there was too much here at West Ham for me to say no.
"The only hard thing was turning down Harry because I love him and I would not be the player I was if it wasn't for him."