parse-address is an npm package that matches addresses against US patterns, with no network call. Its latest version, 1.1.2, was published in June 2022 (npm versions). On the 24 US addresses below it found every street, city, state and ZIP. On 276 addresses from other countries it found no postcode.
Get a free key JavaScript guide
| parse-address 1.1.2 | parseaddr | |
|---|---|---|
| US addresses (24): street, city, state and ZIP right | 24/24 | 24/24 |
| US addresses (24): every labelled field right | 12/24 (no country field, so the 12 inputs ending in "USA" miss it) | 24/24 |
| UK addresses (200): every field right | 0/200 | 197/200 |
| UK postcode found | 0/200 | 200/200 |
| UK city found | 0/200 | 197/200 |
| Other countries (76): every field right | 0/76 | 72/76 |
Inputs, scoring script and every output: benchmarks folder.
> require("parse-address").parseLocation("14 High Street, Oxford OX1 4AG")
{ number: '14', street: 'High', type: 'St' }
> require("parse-address").parseLocation("Hauptstraße 5, 10115 Berlin, Germany")
{ street: 'Hauptstra', suffix: 'e' }
In the first case, Oxford and OX1 4AG are gone. In the second, the ß splits the street name and the number, postcode and city are gone. There is no error, so the loss is easy to miss.
const res = await fetch("https://api.parseaddr.com/v1/parse", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PARSEADDR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ address: "14 High Street, Oxford OX1 4AG" }),
});
const { parsed } = await res.json();
// { house_number: '14', road: 'high street', city: 'oxford', postcode: 'ox1 4ag' }
| parse-address key | parseaddr field |
|---|---|
number | house_number |
prefix + street + type + suffix | road (one string, as written) |
sec_unit_type + sec_unit_num | unit |
city, state | city, state |
zip | postcode |
| none | country, and country_code when you send a country hint |
parseaddr returns lower case and does not abbreviate street types. The free tier is 2,000 calls a month, then plans from £19 a month (pricing).
parseaddr · home · agents · pricing · llms.txt · .md
Pyke Limited, registered in England and Wales, company number 09748427.