The correlations of certain entangled quantum states can be fully reproduced via a local model. We discuss in detail the practical implementation of an algorithm for constructing local models for entangled states, recently introduced by Hirsch et al. [Phys. Rev. Lett. 117, 190402 (2016)] and Cavalcanti et al. [Phys. Rev. Lett. 117, 190401 (2016)]. The method allows one to construct both local hidden state (LHS) and local hidden variable (LHV) models, and can be applied to arbitrary entangled states in principle. Here we develop an improved implementation of the algorithm, discussing the optimization of the free parameters. For the case of two-qubit states, we design a ready-to-use optimized procedure. This allows us to construct LHS models (for projective measurements) that are almost optimal, as we show for Bell diagonal states, for which the optimal model has recently been derived. Finally, we show how to construct fully analytical local models, based on the output of the convex optimization procedure.