Aims. The origin and evolution of the magnetic helicity in the solar corona are not well understood. For instance, the magnetic helicity of an active region is often about 1042 Mx2 (1026 Wb2), but the observed processes whereby it is thought to be injected into the corona do not yet provide an accurate estimate of the resulting magnetic helicity budget or time evolution. The variation in magnetic helicity is important for understanding the physics of flares, coronal mass ejections, and their associated magnetic clouds. To shed light on this topic, we investigate here the changes in magnetic helicity due to electric currents in the corona for a single twisted flux tube that may model characteristic coronal structures such as active region filaments, sigmoids, or coronal loops. Methods. For a bipolar photospheric magnetic field and several distributions of current, we extrapolated the coronal field as a nonlinear force-free field. We then computed the relative magnetic helicity, as well as the self and mutual helicities. Results. Starting from a magnetic configuration with a moderate amount of current, the amount of magnetic helicity can increase by 2 orders of magnitude when the maximum current strength is increased by a factor of 2. The high sensitivity of magnetic helicity to the current density can partially explain discrepancies between measured values on the photosphere, in the corona, and in magnetic clouds. Our conclusion is that the magnetic helicity strongly depends on both the strength of the current density and also on its distribution. Conclusions. Only improved measurements of current density at the photospheric level will advance our knowledge of the magnetic helicity content in the solar atmosphere.