A finitely generated group G acting on a tree so that all vertex and edge stabilizers are infinite cyclic groups is called a generalized Baumslag-Solitar group (GBS group). The centralizer dimension of a group G is the maximal length of a descending chain of centralizers. In this paper we complete a description of centralizers for unimodular GBS groups. This allows us to find the centralizer dimension of all GBS groups and to establish a way to compute it.Theorem 3 Given a reduced labeled graph A such that π 1 (A) is non-abelian group, ∆(π 1 (A)) = {1} and b 1 (A) = n. Then cdim(π 1 (A)) is odd and 3 cdim(π 1 (A)) 2 · |E(A)| + 1.Moreover, for every odd k, 3 k 2·m+1 there exists a labeled graph B m,n with m edges such that b 1 (B m,n ) = n m, ∆(π 1 (B m,n )) = {1} and cdim(π 1 (B m,n )) = k. Theorem 4 Given a reduced labeled graph A such that π 1 (A) is non-abelian group, ∆(π 1 (A)) = {±1} and b 1 (A) = n. Then cdim(π 1 (A)) is odd and 3 cdim(π 1 (A)) 2 · |E(A)| + 3.Moreover, for every odd k, 3 k 2 · m + 3 there exists a labeled graph B m,n with m edges such that 1 b 1 (B m,n ) = n m, ∆(π 1 (B m,n )) = {±1} and cdim(π 1 (B m,n )) = k.Since the proofs are constructive, we do not just describe the centralizer dimension for GBS groups, but also establish a way to compute it. Remark 5 Given a labeled graph A. There is an algorithm to compute cdim(π 1 (A)).The author is grateful to V. A. Churkin for valuable comments and advice.