A bare ~ in LaTeX is a non-breaking space, which is why it never prints. For the relation sign use \sim; for an accent use \tilde; for a literal tilde in text (file paths, Unix home directories) use \textasciitilde or the url package.
All ways to write it
\simbinary ∼ (similar, distributed as)No package needed\tilde{a}accent over one letterNo package needed\widetilde{abc}wide accent over severalNo package needed\textasciitildeliteral ~ in text modeNo package needed\texttt{\~{}}~ in a monospace path or URLNo package needed\url{~user}tilde in a URLPackage: hyperref, urlNot in KaTeX
Commands marked with a package need that \usepackage line in a LaTeX document. “Not in KaTeX” means the command will not render in KaTeX- or MathJax-based tools such as Markdown previews, Jupyter and Confluence math apps; use one of the other forms there.
Example
\tilde{x} = \frac{x - \mu}{\sigma}, \qquad X \sim \text{Poisson}(\lambda)A tilde accent for a standardised variable, and ∼ for a distribution.
Questions
Why does ~ print as a space?
In LaTeX ~ is the non-breaking space. Use \textasciitilde (text) or \sim (math) when you want the glyph.
How do I write ~/Documents in LaTeX?
\texttt{\textasciitilde/Documents}, or \path{~/Documents} from the url package.
Using tilde in Confluence
Confluence Cloud has no built-in LaTeX. With LaTeX Math for Confluence you add a math macro to any page, type \sim and it renders inline or as a block, with a live preview while you edit. The app uses KaTeX, so pick one of the commands above that is not marked “not in KaTeX”.