2. If the complex number $\frac{z+\frac{1}{3}}{z-\frac{1}{3}}$ is purely imaginary, then $|z|=$
2. $\frac{1}{3}$.

Let $z=a+b i$. Then
$$
\begin{aligned}
\text { Original expression }= & \frac{3 z+1}{3 z-1}=1+\frac{2}{3 z-1}=\frac{2}{(3 a-1)+3 b i}+1 \\
& =\frac{(3 a-1)^{2}+9 b^{2}+2(3 a-1)}{(3 a-1)^{2}+9 b^{2}} \\
& -\frac{6 b i}{(3 a-1)^{2}+9 b^{2}}
\end{aligned}
$$

is a pure imaginary number.
$$
\begin{array}{c}
\therefore(3 a-1)^{2}+9 b^{2}+6 a-2=0 \\
\quad \Rightarrow a^{2}+b^{2}=\frac{1}{9} \Rightarrow|z|=\frac{1}{3} .
\end{array}
$$