Skip to content

Blog

Phone number validation: format, numbering plans, line type and live lookups

How phone number validation works layer by layer: parsing, numbering plan checks, line type, live carrier lookups, and what a valid result never proves.

Updated 2026-11-23

Phone number validation checks that a number can exist: it parses what was typed, finds the country, and tests the digits against that country's numbering plan for an allowed length and a range the regulator has opened. A valid result does not prove that the line works or that it belongs to the person who typed it. A live lookup tells you which network serves the number today, and only a one-time code proves possession.

Five questions, five different checks

"Validate a phone number" covers several questions. Each one has its own source of truth, its own cost and its own blind spots.

Check Question it answers Where the answer comes from Cost
Parsing Is this a phone number, and which country does it belong to? The input, plus the + prefix or a country you send Local, instant
Numbering plan Can a number with these digits exist? National plans, compiled in Google's libphonenumber metadata Local, instant
Line type Was the range opened for mobile, landline, VoIP, toll-free, premium rate? The ranges each plan sets aside for each service Local, instant
Live lookup Which network serves the number now, and was it ported? An upstream number-lookup provider, queried at call time A network round trip, paid
Possession Does the person in front of the form hold this phone? A one-time code sent by SMS or voice Seconds to minutes, a message per attempt

Most phone bugs come from asking one layer for another layer's answer. A regex cannot tell you the line type. A valid result cannot tell you who owns the number. A live lookup cannot tell you that the person typing is that owner.

Parsing: turn what people type into one number

People write the same number in many ways. A San Francisco number can arrive as (415) 555-0123, 415.555.0123, +1 415 555 0123, 001 415 555 0123 typed in Europe, or tel:+14155550123 copied from a link. Parsing removes the noise and decides which plan to read.

  • Separators carry no meaning. Spaces, dashes, dots, slashes and parentheses are dropped.
  • Extensions are set aside. ext. 42, x42 or #42 is not part of the number, and E.164 has no room for it.
  • The country comes from the prefix or from you. A leading + means a country calling code follows. A leading 00 means the same thing in most countries, since 00 is the international prefix ITU-T recommends. Without either, the digits are a national number, and you need to know which nation.

That last point is where most validation goes wrong. 06 12 34 56 78 is a valid mobile number in France. Read with a fixed default country of US, it fails. Read with no country at all, it cannot be read. The phone API returns status: "unknown" in that case rather than guessing.

Input Country sent What parsing sees
+44 7400 123456 none A UK number, from the +44 prefix
07400 123456 GB A UK number; the leading 0 is the trunk prefix
07400 123456 none Unknown: no +, no country, so no plan applies
(415) 555-0123 ext. 7 US +14155550123, with extension 7 kept apart
+44 (0)121 234 5678 none A Birmingham landline; the stray trunk 0 is dropped

Why a regular expression is not enough

A pattern such as ^\+?[0-9]{7,15}$ checks characters and length. It accepts +11234567890, which no North American number can be, because area codes never start with 1. It accepts +447400123456789, fifteen digits and far too long for a UK mobile. And it rejects (415) 555-0123, a correct number written the way Americans write it. A regex is fine for instant feedback while someone types. The decision needs the plan.

The numbering plan: can this number exist?

ITU-T Recommendation E.164 sets the frame for every number in the world: a country calling code of one to three digits, then a national number, 15 digits at most in total. Inside that frame, each country runs its own plan. National regulators decide which lengths are allowed and which blocks are open for which service. NANPA administers the North American Numbering Plan behind +1, Ofcom the UK plan, ARCEP the French plan, the Bundesnetzagentur the German one.

Google's libphonenumber collects those plans into metadata, with patterns per country and per type of line. It distinguishes two levels of correctness:

  • Possible: the length is one the country allows. +44 7400 12345 is possible, because nine digits is a legal UK length.
  • Valid: the number also matches a range the plan has opened. +44 7400 12345 is not valid, because UK numbers starting with 7 have ten digits.

A validator that only checks possibility lets through numbers nobody can dial. Ask for validity.

Rules hidden in ten North American digits

The NANP shows how much structure fits in a short number. A number is written NPA-NXX-XXXX: a three-digit area code, a three-digit central office code, then four digits.

Rule of the plan A number that breaks it
The area code starts with a digit from 2 to 9 +1 123-456-7890
The central office code also starts with 2 to 9 +1 201-155-0123
N11 codes, such as 411 and 911, are service codes and never area codes +1 911-555-0123

NANPA also reserves 555-0100 through 555-0199 for fictional use. +1 201-555-0123 is valid in the plan yet assigned to nobody, which makes it a safe test value for forms and code samples. The UK has its own fiction range: Ofcom sets aside 07700 900000 to 07700 900999 for drama, and libphonenumber's data rejects those numbers as invalid.

Plans change

Regulators open new ranges, retire old ones and add overlay area codes when a region runs short of numbers. libphonenumber ships metadata updates in its releases, and a validator is only as current as its copy of that data. A number from a block opened very recently can fail until the data catches up. When a customer insists that a brand-new number is real, believe them and check the first digits against the regulator's announcements.

Line type: what the range was opened for

Each plan reserves ranges for each service, so a valid number also carries a line type. The phone API returns one of mobile, landline, fixed_line_or_mobile, voip, toll_free, premium_rate, shared_cost, personal_number, pager, uan, voicemail or unknown.

Three facts decide how far you can rely on it:

  • North America does not split mobile and landline. Both share area codes, so every geographic +1 number comes back fixed_line_or_mobile.
  • VoIP is labeled only where the plan reserves ranges for it, such as 056 in the UK or 09 in France. Internet phone services that hand out ordinary geographic or mobile numbers look like any other number.
  • The type describes the range, not the phone. A number ported from a landline operator to a mobile one keeps the type of its original range.

The line type decides whether an SMS can arrive, and it is a cheap filter in front of a verification flow: never send a one-time code to a premium-rate number. Mobile, landline or VoIP goes through every type, and the free line type lookup shows it for any number.

Live lookups: who serves the number today

Everything so far reads static plan data. It never touches the phone network, so it cannot see what happened to a number after its range was assigned. And numbers move. Number portability lets a subscriber change operator and keep the number: in the United States and Canada, the Number Portability Administration Center (NPAC) records ported numbers, and in the European Union, Article 106 of the European Electronic Communications Code guarantees portability.

A live lookup asks an upstream number-lookup provider about the number at the time of the call. With "level": "live", the response changes like this:

Field Basic level Live level
carrier.name The operator the range was originally assigned to, when the plan data names one The operator serving the number now
carrier.mcc, carrier.mnc null Mobile country and network codes (ITU-T E.212)
ported null, since the plan cannot see porting true or false
carrier.source numbering_plan live

Pay for it when the current network changes the outcome: routing and pricing SMS, or reviewing a sensitive change such as an account recovery. A live lookup costs 3 credits instead of 1. When the provider fails, the API answers 502 upstream_unavailable and bills nothing. A live lookup sends the number to the lookup provider; the basic level sends it nowhere.

What a live lookup still cannot tell you is who the subscriber is, or whether the phone is switched on. The API never returns the name or address behind a number.

Possession: the step no validation replaces

Validation filters out impossible numbers. It does not tie a number to a person. Anyone can type a valid number that belongs to someone else, by mistake or on purpose. When a number will be used to sign in, recover an account or receive private messages, send a one-time code and mark the number verified only when the code comes back.

Validate before you send that code. Every SMS costs money, and attackers know it. In SMS pumping, also called artificially inflated traffic, bots fill verification forms with numbers on expensive routes and share the revenue of the messages you pay for. A validity and line type check before the send, codes limited to the countries you serve, and per-number and per-IP rate limits remove the cheapest attacks. Stopping fake signups combines these checks with email and IP signals.

Validate a number with the API

Send what the person typed and, when there is no +, the country they picked next to the field:

curl https://api.qelka.com/v1/phone \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone": "07400 123456", "country": "GB"}'

The response has status: "valid", e164: "+447400123456" and line_type: "mobile". Without country, the same input returns status: "unknown".

A basic check of a US number returns the full record:

{
  "id": "lkp_01M84BPXA0RJ291DEC04H84EKA",
  "object": "phone",
  "input": "+14155550123",
  "valid": true,
  "status": "valid",
  "e164": "+14155550123",
  "national": "(415) 555-0123",
  "country": { "code": "US", "name": "United States", "calling_code": "1" },
  "region": "California",
  "timezones": ["America/Los_Angeles"],
  "line_type": "fixed_line_or_mobile",
  "carrier": { "name": null, "mcc": null, "mnc": null, "source": "numbering_plan" },
  "ported": null,
  "credits_used": 1,
  "cached": false
}

line_type is fixed_line_or_mobile because the North American plan does not separate the two. carrier.name is null because libphonenumber's carrier data names no range holder for numbers in the US states.

In JavaScript, on your server, with a timeout and one decision per outcome:

const API = 'https://api.qelka.com/v1'

export async function checkPhone(phone, country) {
  let response
  try {
    response = await fetch(`${API}/phone`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(country ? { phone, country } : { phone }),
      signal: AbortSignal.timeout(5000),
    })
  } catch {
    return { decision: 'accept_unchecked', e164: null }
  }
  if (!response.ok) return { decision: 'accept_unchecked', e164: null }
  const result = await response.json()

  if (result.status === 'unknown') return { decision: 'ask_country', e164: null }
  if (!result.valid) return { decision: 'ask_correction', e164: null }
  if (['premium_rate', 'shared_cost'].includes(result.line_type)) return { decision: 'refuse', e164: null }
  return { decision: 'accept', e164: result.e164, lineType: result.line_type }
}

Failures fail open: if the API is slow or unreachable, the form goes through and you can check the number later. A validation outage should never be the reason nobody can sign up.

What to do with the result

Result In a signup or checkout form Before sending an SMS
valid, mobile Accept and store e164 Send
valid, fixed_line_or_mobile Accept Send and watch delivery reports, or run a live lookup first
valid, landline Accept if your flow can use a call Do not text: call, or ask for a mobile number
valid, voip Accept or flag, by your policy Fine for notices; decide per flow for codes
valid, premium_rate or shared_cost Refuse Never send
invalid Ask for a correction and show an example number for the country Remove from the send
unknown Ask for the country, then check again Fix the country first

Mistakes that cost the most

  • A fixed default country. Default to the visitor's locale or IP country, and let them change it. A US default turns every French or British number typed at home into a failure.
  • Storing what was typed. Store e164. Two spellings of one number then match, and SMS providers accept the value as it is. E.164 explained covers storage in detail.
  • A numeric column. It drops the +. A text column of 16 characters fits any E.164 number.
  • Calling the API from the browser. Your key would ship to every visitor. Validate on the server, and keep the browser to a light length hint.
  • Treating valid as verified. Only a returned code proves possession.
  • Refusing every VoIP number. Some real customers only have one. Decide per flow, not globally.

Try it before you write code

The free phone validator runs the same basic check, 10 times a day without an account. With a test key, numbers are parsed for real and no credits are spent, so you can build the whole integration in test mode. Every field is described in the phone API reference, and the phone validation API page covers pricing and volumes.

Frequently asked questions

How do I check if a phone number is valid?
Parse it with its country, then test it against that country's numbering plan: the length must be allowed and the digits must fall in a range the regulator has opened. Libraries built on Google's libphonenumber do this, and so does the free phone validator. Send the country along with numbers typed without a +, or no check can know which plan to read. Then store the E.164 form of every valid number.
Can you validate a phone number with a regex?
Only loosely. A regex checks characters and length, so it cannot know that North American area codes never start with 0 or 1, that a UK mobile has exactly ten digits after +44, or which ranges a regulator has opened. Use a regex for instant feedback while someone types, and run the real check against numbering plan data on your server before you accept the number.
What is the difference between phone validation and phone verification?
Validation looks at the number itself: can it exist, which country, which line type. It sends nothing and the owner sees nothing. Verification proves that the person in front of your form holds the phone, usually with a one-time code sent by SMS or voice call. Validate first, so you never pay to send a code to an impossible or premium-rate number, then verify when the number will be used to sign in.
Why does a valid phone number not work?
A numbering plan lists the numbers that can exist, not the ones in service. A valid number may never have been assigned, may have been disconnected, or may now belong to a new subscriber. The fictional range 555-0100 to 555-0199 in North America is valid in the plan and assigned to nobody. A live lookup shows the network serving a number today; only a call or a returned code shows that someone answers.
How many digits does a valid phone number have?
ITU-T E.164 caps an international number at 15 digits, country calling code included. Each country sets its own lengths inside that limit: 10 digits after +1 in the United States and Canada, 9 after +33 in France, 10 for a UK mobile after +44, while German numbers vary with the area and the type of line. A correct length is necessary, but it never makes a number valid on its own.
Does phone validation call or text the number?
No. A basic check reads numbering plan data on the server and never contacts the phone network, so the owner of the number sees nothing. A live lookup asks an upstream number-lookup provider which network serves the number. That reads network records, not the handset, and it does not place a call or send a message either. Only a verification code, which you choose to send, reaches the phone.
How much does a phone validation API call cost?
With Qelka, a basic check against the numbering plan costs 1 credit, and a live lookup of the current carrier and porting status costs 3 credits. Errors are not billed, and neither are live lookups whose provider fails. The free plan includes 100 credits a month, and the phone validator runs 10 checks a day without an account. Test keys never spend credits.

Put this check in your product

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