The 26-year-old started just two games in the Capital One Cup for Arsene Wenger's side last term before being sent out on loan to Hannover in January.
|11/4||Arsenal are 11/4 with BetVictor to win the Premier league without Man Utd or Man City
"I'm very happy now that everything is sorted. HSV are a big club, with a lot of quality and great fans," the centre-back told the German club's official website.
"I am convinced that this is the right step for my career.
"In London I would have earned much more money but that has not been decisive. I want to play as much as possible and develop myself and I see in Hamburg the optimum requirements."
Hamburg's director of sport, Oliver Kreuzer, added: "Johan was a priority as the defence is a very important part of our team. He has leadership qualities but is also fast, good in the air and very good on the ball."