Information on the spectral shape of prompt emission in gamma-ray bursts (GRB) is mostly available only at energies $gtrsim10$ keV, where the main instruments for GRB detection are sensitive. The origin of this emission is still very uncertain because of the apparent inconsistency with synchrotron radiation, which is the most obvious candidate, and the resulting need for considering less straightforward scenarios. The inclusion of data down to soft X-rays ($sim$ 0.5 keV), which are available only in a small fraction of GRBs, has firmly established the common presence of a spectral break in the low-energy part of prompt spectra, and the consistency of the overall spectral shape with synchrotron radiation in the moderately fast-cooling regime, the low-energy break being identified with the cooling frequency. In this work we further extend the range of investigation down to the optical band. In particular, we test the synchrotron interpretation by directly fitting a theoretically derived synchrotron spectrum and making use of optical to gamma-ray data. Secondly, we test an alternative model that considers the presence of a black-body component at $sim$keV energies, in addition to a non-thermal component that is responsible for the emission at the spectral peak (100 keV-1 MeV). We find that synchrotron radiation provides a good description of the broadband data, while models composed of a thermal and a non-thermal component require the introduction of a low-energy break in the non-thermal component in order to be consistent with optical observations. Motivated by the good quality of the synchrotron fits, we explore the physical parameter space of the emitting region. In a basic prompt emission scenario we find quite contrived solutions for the magnetic field strength (5 G $<B^prime<40$ G) and for the location of the region where the radiation is produced ($R_gamma>10^{16}$ cm).