In the present study, a two-dimensional numerical code is developed that is capable to predict the performance of a thermoelectric module that includes a p-leg and an n-leg together with top and bottom end plates. The present code can predict the heat flow, electric current, Joule heating, Peltier heating, Thomson heating and efficiency (or COP) of the modules whose properties depend on the temperature. The present numerical code can be used for the design and optimization of a thermoelectric power generator and a Peltier heater/cooler.