The ground state magnetization of nanowires built of ferromagnetic crystallites is considered taking into account the magnetostatic interaction. The criterion of formation of domains is found. The thickness of a domain wall is calculated analytically and the results are compared with the numerical simulations. We show that when the exchange coupling between crystallites is absent its role is played by magnetostatics that ensures the existence of stable domain structure. The direction of the induced anisotropy axis is shown to be determined by the shape of crystallites.