Online Playground
Browse tools

Phone Number Parser

Break a phone number into country, calling code, national number, extension and line type.

Parse a phone number

Try

Processed locally with libphonenumber-js. Nothing you enter is sent to a server.

How it works

Three steps, all in your browser

  1. 1

    Enter one number

    With a + prefix, or choose the default country for a local number.

  2. 2

    Read the breakdown

    Country, calling code, national number, extension, line type and validity appear at once.

  3. 3

    Copy any field

    Each machine-readable value has its own copy button.

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.

FieldValueMeaning
number+16502530000The number in E.164 format. Extension excluded.
countryCallingCode1The digits after the plus sign.
nationalNumber6502530000The number without the country code or trunk prefix.
countryUSTwo-letter ISO code, or undefined for non-geographic numbers.
ext123The extension, kept separate from the number.
isValid()trueLength and digits fit an assigned range.
isPossible()trueOnly the length fits the country.
getType()FIXED_LINE_OR_MOBILEThe 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.

NumberCountryCalling codeNote
+1 416 555 0123Canada+125 countries use this code
+1 876 123 4567Jamaica+125 countries use this code
+7 701 123 4567Kazakhstan+72 countries use this code
+7 840 123 4567Russia+72 countries use this code
+358 18 12345Ă…land Islands+3582 countries use this code
+800 1234 5678None (non-geographic)+800Non-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.

js
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.

FAQ

Questions people ask

What does a phone number parser do?

It splits a raw string into its parts: the country calling code, the national number and any extension, then checks them against the numbering plan of the country. This one uses libphonenumber-js, a port of Google's libphonenumber.

Why does the parser list several countries under "Countries using +1"?

Some calling codes are shared. +1 covers the US, Canada and more than twenty other countries and territories. The parser picks the country of the number from its first digits, and that row lists everyone who uses the same code.

Can it find the carrier or the owner?

No. A phone number parser can tell you where a number is registered and what kind of line it is, but not who owns it or which network it is on today. That needs a carrier database, which this site does not use.