In depth
The object this page shows you
These values are the result of parsing +44 20 7946 0958 with the max data set. They are the fields your own code can read from the parsed number.
| Field or method | Result |
|---|---|
| number | +442079460958 |
| country | GB |
| countryCallingCode | 44 |
| nationalNumber | 2079460958 |
| isValid() | true |
| isPossible() | true |
| getType() | FIXED_LINE |
| formatInternational() | +44 20 7946 0958 |
| formatNational() | 020 7946 0958 |
| getURI() | tel:+442079460958 |
isPossible() and isValid() are different checks
isPossible() checks only that the length fits the country. isValid() also checks the digits against the ranges assigned in that country. The library's author prefers isPossible() for forms, because numbering plans change and an out-of-date copy of the library could reject a newly assigned range. Here is how they differ on real input.
| Input | Default country | isPossible() | isValid() |
|---|---|---|---|
| 0000000000 | US | true | false |
| 12345 | US | false | false (TOO_SHORT) |
| +91 1000000000 | true | false |
Strict parsing with extract: false
By default the parser extracts a number from surrounding text, which mimics Google's library. The input "Call: (213) 373-4253" parses to +12133734253. With extract: false it returns undefined, so text around the number makes it fail. Tick "Strict parsing" above to see both, together with the code to copy.
min, max and mobile builds
This playground runs the max data set so every field is filled in. If your project uses the default min build, getType() returns nothing for many countries, and isValid() is more lenient because it does not check digits against exact ranges for most countries. Choose the build in the import path: libphonenumber-js, libphonenumber-js/max or libphonenumber-js/mobile. The install guide has measured sizes for each.