We put forth a variational principle for the Zakharov-Shabat (ZS) equations, which is the basis of the inverse scattering transform of a number of important nonlinear PDE's. Using the variational representation of the ZS equations, we develop an approximate analytical technique for finding discrete eigenvalues of the complex spectral parameter in the ZS equations for a given pulse-shaped potential, which is equivalent to the physically important problem of finding the soliton content of the given initial pulse. We apply the technique to several particular shapes of the pulse and demonstrate that the simplest version of the variational approximation, based on trial functions with one or two free parameters, proves to be fully analytically tractable, and it yields threshold conditions for the appearance of the first soliton, or of the first soliton pair, which are in a fairly good agreement with available numerical results. However, more free parameters are necessary to allow prediction of additional solitons produced by the given pulse.