# haversine-distance

> Haversine formula in Javascript, in meters, nothing else

Latest version **1.2.4** (published 2025-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install haversine-distance
pnpm add haversine-distance
yarn add haversine-distance
bun add haversine-distance
```

## Health

**Score 45/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2025-06-18 |
| First published | 2015-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 83 |
| Author | Daniel Cousens |
| Maintainers | dcousens |
| Keywords | haversine, distance, geography, latitude, longitude, coordinates, math, meters |

## Links

- npm: https://www.npmjs.com/package/haversine-distance
- Repository: https://github.com/dcousens/haversine-distance
- Issues: https://github.com/dcousens/haversine-distance/issues
- npm.io page: https://npm.io/package/haversine-distance

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.2.4 (latest) — 2025-06-18
- 1.2.3 — 2024-06-07
- 1.2.2 — 2024-06-06
- 1.2.1 — 2020-03-09
- 1.1.6 — 2019-10-15
- 1.1.5 — 2019-10-15
- 1.1.4 — 2018-03-16
- 1.1.3 — 2016-01-02
- 1.1.2 — 2015-10-08
- 1.1.1 — 2015-10-08
- 1.1.0 — 2015-10-08
- 1.0.1 — 2015-05-05
- 1.0.0 — 2015-05-05

## README

# haversine-distance
[![Version](http://img.shields.io/npm/v/haversine-distance.svg)](https://www.npmjs.org/package/haversine-distance)
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

Haversine formula in Javascript, in meters, nothing else


## Example

### Import

```javascript
const haversine = require('haversine-distance')
// or
import haversine from 'haversine-distance'
```

### Usage

```javascript
const a = { latitude: 37.8136, longitude: 144.9631 }
const b = { latitude: 33.8650, longitude: 151.2094 }

console.log(haversine(a, b)) // 714504.18 (in meters)
```

Alternative forms such as `lat`, `lng` and `lon` work too, with mixed support:

```javascript
const a = { lat: 37.8136, lng: 144.9631 }
const b = { lat: 33.8650, lon: 151.2094 }

console.log(haversine(a, b)) // 714504.18 (in meters)
```

### GeoJSON support

```javascript
const a = [144.9631, 37.8136]
const b = [151.2094, 33.865]

console.log(haversine(a, b)) // 714504.18 (in meters)
```


## LICENSE [MIT](LICENSE)

---
_Source: https://npm.io/package/haversine-distance · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
