In depth
What each field means
This is the parsed result of +1 650 253 0000 ext. 123, produced by the library. Every field is something your own code can read after parsing.
| Field | Value | Meaning |
|---|---|---|
| number | +16502530000 | The number in E.164 format. Extension excluded. |
| countryCallingCode | 1 | The digits after the plus sign. |
| nationalNumber | 6502530000 | The number without the country code or trunk prefix. |
| country | US | Two-letter ISO code, or undefined for non-geographic numbers. |
| ext | 123 | The extension, kept separate from the number. |
| isValid() | true | Length and digits fit an assigned range. |
| isPossible() | true | Only the length fits the country. |
| getType() | FIXED_LINE_OR_MOBILE | The line type, where the country's data allows. |
Shared and special calling codes
A calling code does not always identify one country. +1 is shared across the North American plan and +7 by Russia and Kazakhstan, and the library tells them apart from the first digits of the national number. Nine codes, including +800 and +882, belong to no country at all. These are real parse results.
| Number | Country | Calling code | Note |
|---|---|---|---|
| +1 416 555 0123 | Canada | +1 | 25 countries use this code |
| +1 876 123 4567 | Jamaica | +1 | 25 countries use this code |
| +7 701 123 4567 | Kazakhstan | +7 | 2 countries use this code |
| +7 840 123 4567 | Russia | +7 | 2 countries use this code |
| +358 18 12345 | Ă…land Islands | +358 | 2 countries use this code |
| +800 1234 5678 | None (non-geographic) | +800 | Non-geographic code |
What the parser does not know
The parser reads the structure of a number and checks it against the numbering plan. It cannot say who owns the number, which network it is on today, or where the phone is. libphonenumber-js has no geolocation and no carrier data, and numbers move between carriers when people port them.
Using the parsed fields in code
The values on this page are exactly what your own code gets. Store the number field, which is E.164, and read the rest only when you need it.
import { parsePhoneNumberFromString } from 'libphonenumber-js/max'
const phone = parsePhoneNumberFromString('+1 650 253 0000 ext. 123')
if (phone) {
save(phone.number) // '+16502530000'
phone.ext // '123' (kept separate)
phone.country // 'US'
}What happens to extensions
An extension is kept apart from the number, so +1 650 253 0000 and the same number with ext. 123 share one E.164 value and differ only in ext. If you store only the E.164 number you lose the extension, so keep ext in its own column when you need it.