By introducing a Tannakian formalism for Drinfeld modules and relating it to the Galois theory of certain Frobenius semi-linear difference equations, we determine the transcendence degrees of fields generated by periods of Drinfeld modules and more generally Anderson t-modules. More precisely, we show that the transcendence degree of the period matrix of a Drinfeld module is equal to the dimension of its Galois group. As an application, we prove that Carlitz logarithms of algebraic numbers that are linearly independent over F_q(t) are algebraically independent.