5. Given that the complex number $z$ satisfies $z+|z|=3+\mathrm{i}$. Then $z=$
5. $\frac{4}{3}+$ i.

Let $z=x+\mathrm{i}$. Then
$$
\begin{array}{l}
x+\mathrm{i}+\sqrt{x^{2}+1}=3+\mathrm{i} \\
\Rightarrow x+\sqrt{x^{2}+1}=3 \\
\Rightarrow x=\frac{4}{3} \Rightarrow z=\frac{4}{3}+\mathrm{i}
\end{array}
$$