 <p>If you are using the <a href="https://developers.google.com/maps/documentation/distancematrix/" rel="nofollow">Google Maps Distance Matrix API</a>, there is another field in the <code>distance</code> object called <code>value</code> that has a Number value. As documented in the API, the units is metres.</p> <p>But to answer your original question, I would remove all non-digit characters from the string using a regular expression:</p> <pre><code>var dist = '1,525 KM'; dist = Number(dist.replace(/[^\d]/g, '')); </code></pre>