It has been shown by van den Berg and Steif (Ann. Probab. 27 (1999) 1501–1522) that the subcritical and critical Ising model on $\mathbb{Z}^{d}$ is a finitary factor of an i.i.d. process (ffiid), whereas the super-critical model is not. In fact, they showed that the latter is a general phenomenon in that a phase transition presents an obstruction for being ffiid. The question remained whether this is the only such obstruction. We make progress on this, showing that certain spatial mixing conditions (notions of weak dependence on boundary conditions, not to be confused with other notions of mixing in ergodic theory) imply ffiid. Our main result is that weak spatial mixing implies ffiid with power-law tails for the coding radius, and that strong spatial mixing implies ffiid with exponential tails for the coding radius. The weak spatial mixing condition can be relaxed to a condition which is satisfied by some critical two-dimensional models. Using a result of the author (Spinka (2018)), we deduce that strong spatial mixing also implies ffiid with stretched-exponential tails from a finite-valued i.i.d. process. We give several applications to models such as the Potts model, proper colorings, the hard-core model, the Widom–Rowlinson model and the beach model. For instance, for the ferromagnetic $q$-state Potts model on $\mathbb{Z}^{d}$ at inverse temperature $\beta $, we show that it is ffiid with exponential tails if $\beta $ is sufficiently small, it is ffiid if $\beta <\beta _{c}(q,d)$, it is not ffiid if $\beta >\beta_{c}(q,d)$ and, when $d=2$ and $\beta =\beta _{c}(q,d)$, it is ffiid if and only if $q\le 4$.