We show a sharp fractional Moser-Trudinger type inequality in dimension $1$, i.e., for any interval $I\Subset \mathbb R $ and $p\in (1,\infty)$ there exists $\alpha_p>0$ such that $$ \sup_{u\in \tilde H^{\frac 1p,p}(I): \|(-\Delta)^\frac{1}{2p}u\|_{L^p(I)}\le 1} \int_I e^{\alpha_p |u|^\frac{p}{p-1}}dx = C_p|I|, $$ and $\alpha_p$ is optimal in the sense that $$ \sup_{u\in \tilde H^{\frac 1p,p}(I): \|(-\Delta)^\frac{1}{2p}u\|_{L^p(I)}\le 1} \int_I h(u) e^{\alpha_p |u|^\frac{p}{p-1}}dx = +\infty, $$ for any function $h:[0,\infty) \to [0,\infty)$ with $\lim_{t\to\infty}h(t)=\infty$. Here, $\tilde H^{\frac 1p,p}(I)=\{u\in L^p( \mathbb R ): (-\Delta)^\frac{1}{2p}u\in L^p( \mathbb R ), \mathrm{supp}(u)\subset \bar I\}$. Restricting ourselves to the case $p=2$, we further consider for $\lambda>0$ the functional $$ J(u):=\frac{1}{2}\int_{ \mathbb R }|(-\Delta)^\frac14 u|^2 dx - \lambda\int_I \left (e^{\frac12 u^2}-1 \right )dx, \quad u\in \tilde H^{\frac{1}{2},2}(I), $$ and prove that it satisfies the Palais-Smale condition at any level $c\in (-\infty,\pi)$. We use these results to show that the equation $$ (-\Delta)^\frac12 u =\lambda u e^{\frac{1}{2}u^2}\quad \text{in }I, $$ has a positive solution in $\tilde H^{\frac12,2}(I)$ if and only if $\lambda\in (0,\lambda_1(I))$, where $\lambda_1(I)$ is the first eigenvalue of $(-\Delta)^\frac12$ on $I$. This extends to the fractional case for some previous results proven by Adimurthi for the Laplacian and the $p$-Laplacian operators. Finally, with a technique by Ruf, we show a fractional Moser-Trudinger inequality on $ \mathbb R $.