Skip to content

Phone

Test a phone number against libphonenumber metadata

See what Google's libphonenumber metadata says about a number: isValid, isPossible, type, region, every format and a JavaScript snippet that reproduces it.

Runs in your browserNothing you paste or open here leaves this page. No account, no daily limit.

Try an example
Valid number

The length and the leading digits match a range the numbering plan uses.

isValid
true
isPossible
true
Type
MOBILE
Region
GB
Country calling code
+44
National significant number
7400123456
Extension
None
Possible countries
GB
Non-geographic
false
E.164
+447400123456
International
+44 7400 123456
National
07400 123456
RFC 3966
tel:+447400123456
From the US
011 44 7400 123456
From the UK
07400 123456

JavaScript snippet

import { parsePhoneNumberFromString } from 'libphonenumber-js/max'

const phone = parsePhoneNumberFromString('+44 7400 123456')

phone.isValid()         // true
phone.getType()         // 'MOBILE'
phone.country           // 'GB'
phone.number            // '+447400123456'
phone.formatNational()  // '07400 123456'
API access
Unlock with a free account

More with a free account

This page runs in your browser. A free account adds the checks that need our servers.

Unlock these fields

How to read the result

The playground parses one number with a default country, then shows what libphonenumber's metadata says about it: the checks, the parts of the number, every format, and a snippet to reproduce it.

Field What it means What to do with it
isValid true when the length fits and the digits fall in a range of the country's plan. The answer to "is this a real number in its plan".
isPossible true when the length fits some kind of number in that country. Digits are not checked. Use it for quick feedback while someone types, never as the final check.
Type The libphonenumber type: FIXED_LINE, MOBILE, FIXED_LINE_OR_MOBILE, TOLL_FREE, PREMIUM_RATE, SHARED_COST, VOIP, PERSONAL_NUMBER, PAGER, UAN, VOICEMAIL. Empty for an invalid number. Decide whether to text, call or refuse it.
Region The ISO 3166-1 alpha-2 code of the country or territory, such as GB or GG. Empty for non-geographic numbers such as +800.
Country calling code The code after the plus sign, such as 44. Several regions can share it.
National significant number The digits after the calling code, without trunk prefix, such as 7400123456. Store E.164 instead. This is its second half.
Extension The extension, when you typed one with ext., x or #. Keep it next to the number. E.164 has no room for it.
Possible countries The regions the number could belong to under its calling code. More than one means the digits did not settle it.
E.164 The international form with + and no spaces, such as +447400123456. The form to store and compare on.
International With spaces, such as +44 7400 123456. Print it, or show it to people abroad.
National As written inside the country, such as 07400 123456. Show it to local users.
RFC 3966 A tel: URI, such as tel:+447400123456;ext=99. Use it in links, so a tap starts a call.
From the US How to dial it from the United States, such as 011 44 7400 123456. Instructions for US callers.
From the UK How to dial it from the United Kingdom, such as 00 44 7400 123456, or the national form for a UK number. Instructions for UK callers.
JavaScript snippet Code that reproduces the parse with libphonenumber-js. Paste it into your project to compare results.
API access Locked. Validation, region, time zones and carrier from your code. Needs a free account.

The formats appear for every possible number, valid or not: +1 123 456 7890 gets an E.164 form while isValid reads false. A format is not a validation. The playground runs in your browser, with no account and no daily limit.

How the playground works

  1. Parse. The input is read by libphonenumber-js with its max metadata, the full set that holds every type pattern. A number that starts with + carries its country. Without a +, the default country you pick decides how the digits are read, including its trunk prefix and its international prefix.
  2. Fill the gaps the way the API does. With no default country, a leading 00 is read like +. With a default country that shares its calling code with others, such as Jersey under +44, the number is placed in that country when it is valid there.
  3. Check. isPossible tests the length, isValid tests the length and the digit patterns, and the type comes from the type patterns the number matches. A number that matches both the fixed-line and the mobile patterns gets FIXED_LINE_OR_MOBILE.
  4. Format. E.164, international, national, RFC 3966 and the two out-of-country formats are produced from the metadata's formatting rules.

The metadata comes from Google's libphonenumber, whose maintainers follow the numbering plans that national regulators publish. The versions in use are on the data sources page. The site's phone validator and the phone API run the same parsing code.

Possible or valid: what each check catches

Input isPossible isValid Why
+44 7400 123456 true true Right length, and 7400 is a UK mobile range.
+44 7400 1234 false false Eight digits after +44 is too short for any UK number.
+1 123 456 7890 true false Ten digits fits +1, but no area code starts with 1.
+1 211 555 0123 true false 211 is an N11 code, used for dialing services, not an area code.
+33 7 00 00 00 00 true false Nine digits fits France, but the plan uses no range starting 07 00.
+1 201 555 0123 true true A valid range. 555-01XX numbers are fictional, yet the plan accepts them.

isPossible is cheap and tolerant, which suits typing feedback. isValid is the check to store a number on. Neither says whether a line works.

Shared calling codes and possible countries

Some calling codes serve several regions, and libphonenumber picks the region from the leading digits of the national number.

Input Region Type
+1 201 555 0123 US FIXED_LINE_OR_MOBILE
+1 242 357 1234 BS, the Bahamas MOBILE
+1 809 234 5678 DO, the Dominican Republic FIXED_LINE_OR_MOBILE
+44 7781 123456 GG, Guernsey MOBILE
+7 701 234 5678 KZ, Kazakhstan MOBILE
+262 692 12 34 56 RE, Réunion MOBILE

When a number under a shared code is invalid, the region stays empty and possible countries lists every candidate: for +1 123 456 7890, that is every region of the North American plan, from the United States and Canada to Jamaica and Guam. Non-geographic codes have no region at all: +800 is the code of Universal International Freephone Numbers, defined by ITU-T: +800 1234 5678 is valid, of type TOLL_FREE, with no region.

From libphonenumber types to API line types

If you call the phone API next to the library, its line_type field uses lower-case names for the same types:

libphonenumber getType() API line_type Line type on the site
MOBILE mobile Mobile
FIXED_LINE landline Landline
FIXED_LINE_OR_MOBILE fixed_line_or_mobile Landline or mobile
VOIP voip VoIP
TOLL_FREE toll_free Toll-free
PREMIUM_RATE premium_rate Premium rate
SHARED_COST shared_cost Shared cost
PERSONAL_NUMBER personal_number Personal number
PAGER pager Pager
UAN uan Universal access number
VOICEMAIL voicemail Voicemail
undefined unknown Unknown

The line type lookup explains what each type means for SMS and calls, with examples by country.

min, max and mobile metadata

libphonenumber-js lets you choose how much metadata to load, to keep bundles small. The choice changes results:

  • min, the default import. It holds the lengths and formatting rules but not the digit patterns, so isValid behaves like isPossible, and getType returns undefined for most countries.
  • max, imported from libphonenumber-js/max. The full set: strict isValid and every type. Google's own library always works with the full metadata. This playground and its snippet use it.
  • mobile, imported from libphonenumber-js/mobile. The full set restricted to mobile numbers: other types can come back as not valid or without a type.

If your form accepts numbers that this playground rejects, check the import first. A bare import ... from 'libphonenumber-js' loads min.

Reproduce the result in your code

The snippet under the result is ready to paste. For 0049 1512 3456789 with no default country, it reads:

javascript
import { parsePhoneNumberFromString } from 'libphonenumber-js/max'

const phone = parsePhoneNumberFromString('+4915123456789')

phone.isValid()         // true
phone.getType()         // 'MOBILE'
phone.country           // 'DE'
phone.number            // '+4915123456789'
phone.formatNational()  // '01512 3456789'

Three details make the snippet match the playground:

  • It imports from libphonenumber-js/max, for the full metadata.
  • It passes your default country as the second argument when you chose one, such as parsePhoneNumberFromString('(201) 555-0123', 'US').
  • When you typed a number with 00 and no country, it writes the number with + instead, since the playground reads 00 that way.

parsePhoneNumberFromString returns undefined for input that is not a phone number, or a number without a country code when no default country is given. Check for it before calling methods.

Surprises worth knowing

  • National formats keep local habits. A Russian mobile, +7 912 345 67 89, is written 8 (912) 345-67-89 nationally, with the trunk prefix 8. Japanese numbers use hyphens: +81 50 1234 5678 becomes 050-1234-5678.
  • Some zeros are part of the number. Italian landlines keep their 0 after +39: +39 06 1234 5678. Do not strip it.
  • Extensions survive parsing. +44 7400 123456 ext 99 is valid, with extension 99, a national form of 07400 123456 x99 and a URI of tel:+447400123456;ext=99.
  • A default country can mislead. Local digits read with the wrong country can land in a valid range there. Try (201) 555-0123 with the United Kingdom as default: it parses as a London number.
  • Plans change. Regulators open and close ranges, and each metadata release follows. A number valid today can be invalid in an old copy of the library, so update it regularly where you validate.

The phone number regex tester shows why patterns written by hand drift from these rules, and the phone number formatter covers the formats in more depth.

When to call the API instead

libphonenumber answers questions about the numbering plan. Some questions need data it does not have:

Question libphonenumber Phone API
Valid in its plan? Type? Formats? Yes Yes, same code and metadata
State, region or city of the range Not in libphonenumber-js Yes, from Google's geocoding files and the NANPA area code report
Time zones of the range Not in libphonenumber-js Yes, from Google's time zone file
Operator the range was assigned to Not in libphonenumber-js Yes, at the basic level, for 1 credit
Carrier serving the number today No Yes, at the live level, for 3 credits
Ported or not No Yes, at the live level
Consumer complaints to the FTC No Yes, through the phone spam reports endpoint

Validating on your server also keeps one metadata version for every client, instead of whatever each browser cached. The phone API reference documents every field, the guide Validate signup forms shows where to call it, and a free account includes 100 credits a month. For a whole file of numbers, the phone list cleaner runs the same library in your browser.

Same check through the API

One HTTPS call, one credit. The response below is the real schema returned by the API.

cURL
curl https://api.qelka.com/v1/phone \
  -H "Authorization: Bearer sk_test_your_key" \
  -H "Content-Type: application/json" \
  -d '{"phone":"+12015550123","level":"basic"}'
JavaScript
const response = await fetch("https://api.qelka.com/v1/phone", {
  method: "POST",
  headers: {
    Authorization: "Bearer sk_test_your_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    phone: "+12015550123",
    level: "basic",
  }),
});
const result = await response.json();
{
  "id": "lkp_01M84QZDVBQCJAMBE4TJB6VRAC",
  "object": "phone",
  "input": "+12015550123",
  "valid": true,
  "status": "valid",
  "e164": "+12015550123",
  "national": "(201) 555-0123",
  "country": {
    "code": "US",
    "name": "United States",
    "calling_code": "1"
  },
  "region": "New Jersey",
  "timezones": [
    "America/New_York"
  ],
  "line_type": "fixed_line_or_mobile",
  "carrier": {
    "name": null,
    "mcc": null,
    "mnc": null,
    "source": "numbering_plan"
  },
  "ported": null,
  "credits_used": 1,
  "cached": false
}

Bulk and pricing

  • Upload a CSV of up to 2,000,000 rows from the dashboard or the API, pick the column, get the results back as a CSV.
  • Every check costs 1 credit, live phone lookups cost 3. Cached results are billed the same way; calls that fail upstream are not billed.
  • The free plan includes 100 credits every month. Paid plans start at $29 for 10,000 credits.

Frequently asked questions

What is libphonenumber?
An open-source library from Google, under the Apache License 2.0, for parsing, formatting and validating phone numbers. Its core is metadata: for every country, the lengths, prefixes and patterns of each kind of number, plus the formatting rules, maintained from national numbering plans. Android uses it, and ports exist for many programming languages. This playground runs its metadata through libphonenumber-js.
What is the difference between libphonenumber and libphonenumber-js?
libphonenumber is Google's library, written in Java, C++ and JavaScript. libphonenumber-js is an independent rewrite in modern JavaScript, under the MIT license, that reads the same metadata. It focuses on parsing and formatting personal numbers, skips some special cases such as short codes, and does not ship Google's geocoding data. Results generally match when both use the full metadata of the same version.
What is the difference between isPossible and isValid?
isPossible only checks the length: does the number have a digit count that some kind of number in its country can have? isValid checks the length and then the digits against the country's patterns, so the leading digits must belong to a range the plan uses. +1 123 456 7890 is possible, ten digits under +1, but not valid, since no area code starts with 1.
Why is a number valid here but invalid in my app, or the reverse?
Three usual causes. Your app may load the default min metadata of libphonenumber-js, where isValid only checks the length. Your app may run an older or newer metadata version, and plans change. Or your app passes a different default country, which changes how numbers without + are read. Paste the snippet from this page into your project to compare like with like.
Why does getType return undefined?
Either the number is not valid, and invalid numbers have no type, or your code uses metadata without the type patterns. The default min metadata of libphonenumber-js leaves them out, so getType returns undefined for most countries. Import from libphonenumber-js/max, as the snippet does, to get FIXED_LINE, MOBILE, TOLL_FREE and the other types.
What does FIXED_LINE_OR_MOBILE mean?
The number matches both the fixed-line and the mobile patterns of its country, so the plan cannot say which it is. Every geographic number of the North American plan returns it, because the US, Canada and their neighbors draw landlines and mobiles from the same area codes and exchanges. A few ranges elsewhere do too. Only the network knows, which is what a live lookup asks.
What is the national significant number?
The digits that follow the country calling code in the international form, without any trunk prefix. For +44 7400 123456 it is 7400123456: the UK trunk prefix 0 belongs to national dialing and is not part of it. Some countries keep a leading 0 that is part of the number itself, as Italy does for landlines: +39 06 1234 5678 has 0612345678.
How do I parse a number written with 00 or 011 in front?
Give the library a default country: it then reads that country's international prefix, so 011 61 2 3456 7890 with US as default is an Australian number. With no default country, this playground also reads a leading 00 like a plus sign, and its snippet writes the number with + so the library gives the same answer. A leading 011 without a country stays unresolved.
What are possible countries?
The regions a number could belong to, given its calling code and digits. Several countries share some calling codes: +1 covers the United States, Canada and much of the Caribbean, +44 covers the UK, Guernsey, Jersey and the Isle of Man, and +7 covers Russia and Kazakhstan. For a valid number the list usually holds one region; for an invalid one, it can hold all of them.
Does isValid mean the number is in service?
No. Valid means the number sits in a range the numbering plan uses for some kind of service. The library never contacts a network, so it cannot know whether the line is assigned, connected or switched off. The fictional US range 555-0100 to 555-0199 is a good test: those numbers come back valid, and nobody answers them.
Is the number I type sent to a server?
No. The playground runs in your browser: the libphonenumber-js code and its metadata are loaded with the page, and parsing happens on your device. Nothing you type is sent to our servers or stored. That is also why it needs no account and has no daily limit, unlike the checks that read the network or our databases.
How do I write a number for dialing from another country?
Read the From the US and From the UK rows. They use libphonenumber's out-of-country format: the international prefix of the calling country, then the country calling code and the national significant number. From the US that prefix is 011, from the UK 00. Within the North American plan, a +1 number is dialed from the US with a leading 1 instead.
Which metadata version does the playground use?
The version bundled with the site's validation code, which the data sources page names: the libphonenumber-js release and the Google metadata release it is built on. The API uses the same code, so a number gets the same validity and type here and in an API response. When the library is updated, results for recently changed ranges can change too.
Can libphonenumber tell me the carrier of a number?
Google's library ships a carrier file that names the operator a range was originally assigned to, and libphonenumber-js does not include it. Neither follows ported numbers. The phone API returns the original operator from Google's file at the basic level and asks the network for the carrier serving the number today at the live level, for 3 credits.

Put this check in your product

Get an API key in under a minute. 100 free credits every month, no card required.

  • 100 free credits a month
  • No card
  • Test keys spend nothing
  • Cancel any time