We prove a Hardy inequality on convex sets, for fractional Sobolev-Slobodecki\u{\i} spaces of order $(s,p)$. The proof is based on the fact that in a convex set the distance from the boundary is a superharmonic function, in a suitable sense. The result holds for every $1