This is a consequence of Levy's Inversion Formula (aka Fourier Inversion Theorem). If $\varphi$ is the CF of $X$ and $\int_{\mathbb{R}}|\varphi(\theta)|d\theta < \infty$ then $X$ is absolutely continuous with density $$ f(x)= \frac{1}{2\pi}\int_\mathbb{R}e^{-i\theta x}\varphi(\theta)d\theta. $$

(Here we are using the definition $\varphi(\theta) = E[e^{i\theta X}]$, else the constant factor out front might be different.)

Once we know this result it is easy to calculate the density given a CF, just plug into the formula. For example, plug in $\varphi(\theta)= \exp(-\frac12 \theta^2)$ and check that you get $f(x) = \frac{1}{\sqrt{2\pi}}\exp(-\frac12 x^2)$, this is the case of $X \sim N(0,1)$.