We present an extension of the Nemov algorithm (Nemov V.V. 1988 Nucl. Fusion 28 1727) to compute the magnetic coordinates in stellarators and their associated metric coefficients, requiring only a knowledge of the magnetic field and field line tracing techniques. The method is not limited to the core of the plasma, but also applies to island chains and Scrape-Off Layer regions. The procedure allows the computation of the Clebsch components of the magnetic field by transforming the magnetic differential equations for the radial and angular coordinates into initial-value problems involving field line tracing. Moreover, it has been optimized for numerical accuracy by minimizing recourse to derivatives of derived quantities. Illustrative applications of the algorithm, as applied to W7-X, including a numerical benchmark for the core region, are presented.