We can construct the unitary transformation for change of basis from $x$ to number operator $n$ in harmonic oscillator by using $a|0\rangle=0$ and then multiply $\langle x|$ to the both side and calculating $\langle x | 0 \rangle$ and then find $\langle x | p \rangle$ and finally use the completeness relation to find the transformation.
Now I would like to somehow find the transformation for a free, real Klein-Gordon Lagrangian with $[\phi(x)]$ being the field operator. How can we construct a unitary transformation from occupation number $|n \rangle$ basis to $|\phi \rangle$ basis?