This is called Poincare's Lemma. I will write the standard version, in a neighborhood around the origin. The usual phrasing is to say that a closed form is locally exact, the fact that this is not globally true is the stuff of cohomology. This is from pages 94-96 of Calculus on Manifolds by Michael Spivak.
Given your divergence-free vector field $(F_1(x,y,z), \; F_2(x,y,z), \; F_3(x,y,z)),$ the $x$-coordinate of the new vector field $G$ is
$$ G_1(x,y,z) = \int_0^1 \; \left( \; t z F_2(tx, ty,tz) - t y F_3(tx, ty,tz) \; \right) \; dt, $$
the $y$-coordinate is
$$ G_2(x,y,z) = \int_0^1 \; \left( \; t x F_3(tx, ty,tz) - t z F_1(tx, ty,tz) \; \right) \; dt, $$
with $z$-coordinate
$$ G_3(x,y,z) = \int_0^1 \; \left( \; t y F_1(tx, ty,tz) - t x F_2(tx, ty,tz) \; \right) \; dt. $$
Note that fractions tend to show up if you have any exponents. I did a test run with a random field, $$ H = (xyz, \; x y^2 z^3, \; x y^3 z^5).$$ I then took the curl to get
$$ F = \nabla \times H = ( 3 x y^2 z^5 - 3 x y^2 z^2, \; x y - y^3 z^5, \; y^2 z^3 - x z).$$
The three components are what I am calling $F_1,F_2,F_3.$ We know that $F$ is a curl, by construction, and we know it is divergence free (check!). Going through Poincare's recipe, after fixing a few of my bookkeeping errors, gave instead
$$ G_1 = \frac{1}{2} x y z - \frac{1}{10} y^3 z^6 - \frac{1}{7} y^3 z^3,$$
$$ G_2 = \frac{4}{7} x y^2 z^3 - \frac{1}{4} x^2 z - \frac{3}{10} x y^2 z^6,$$
$$ G_3 = \frac{4}{10} x y^3 z^5 - \frac{1}{4} x^2 y - \frac{3}{7} x y^3 z^2.$$
This has a bit of a different appearance from $H.$ That is fine. As $H,G$ have the same curl, it follows merely that $(G-H)$ is the gradient of some function.
On that note, if you have a curl-free field $W = (W_1, W_2, W_3),$ it is the gradient of a function $f$ given by
$$ f(x,y,z) = \int_0^1 \; \left( \; x W_1(tx, ty,tz) + y W_2(tx, ty,tz) + z W_3(tx, ty,tz) \; \right) dt.$$