Spectral analysis is performed for a digital message produced by a variable-length encoder driven by a stationary memoryless source. In particular, closed form expressions are derived for both the continuous and the discrete part of the spectral density. The continuous part turns out to be a rational function of

,where

is the symbol period, whereas the discrete part exhibits in general spectral lines at multiple integers of

, where

is the greatest common divisor of the codeword lengths. As an application of the theory explicit formulas are derived for the spectra of B

ZS and HDB

codes.