PhoneNumberParser 2.14.0

.NET 7.0 .NET Standard 2.0
dotnet add package PhoneNumberParser --version 2.14.0
NuGet\Install-Package PhoneNumberParser -Version 2.14.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PhoneNumberParser" Version="2.14.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PhoneNumberParser --version 2.14.0
#r "nuget: PhoneNumberParser, 2.14.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PhoneNumberParser as a Cake Addin
#addin nuget:?package=PhoneNumberParser&version=2.14.0

// Install PhoneNumberParser as a Cake Tool
#tool nuget:?package=PhoneNumberParser&version=2.14.0

Phone Number Parser

A library for parsing phone numbers, providing validity of phone numbers including national destination codes (aka area codes) and subscriber numbers (aka line numbers) based upon published numbering plans for each country. Additional attributes such as the kind of phone number (Mobile, Geographic or Non-Geographic) are also included, and all parsing is performed locally within the library using embedded in-memory data files.

Builds for:

  • .NET 7.0
  • .NET Standard 2.1 - supports .NET Core 3.0 or newer and .NET 5.0 or newer
  • .NET Standard 2.0 - supports .NET Framework 4.6.2 or newer, although projects will need to be built with a minimum C# language version of 9.0 due to use of init only properties
using PhoneNumbers;

// Parsing a phone number is achieved via the `PhoneNumber.Parse` method (or alternatively via `PhoneNumber.TryParse`). Any spaces, hyphens or other formatting in the input string is ignored.
var phoneNumber = PhoneNumber.Parse("+441142726444"); // or Parse("01142726444", "GB")

phoneNumber.NationalDestinationCode;     // 114     (aka area code)
phoneNumber.SubscriberNumber;            // 2726444 (aka line number)

// Country specific information is accessible via the Country property, for example:
phoneNumber.Country.CallingCode;         // +44
phoneNumber.Country.Iso3166Code;         // GB
phoneNumber.Country.Name;                // United Kingdom
phoneNumber.Country.TrunkPrefix;         // 0

// There are 3 subclasses of PhoneNumber, the correct type to cast to can be determined by inspecting the PhoneNumberKind property. Cast as appropriate to access additional properties.
var geographicPhoneNumber = (GeographicPhoneNumber)phoneNumber;
geographicPhoneNumber.GeographicArea;    // Sheffield

// The phone number can be formatted in the following ways, the default format output can be round tripped via `PhoneNumber.Parse()` to make database persistence straightforward.
phoneNumber.ToString();                  // +441142726444      (defaults to E.164 format)
phoneNumber.ToString("E.164");           // +441142726444      (E.164 format)
phoneNumber.ToString("E.123");           // +44 114 2726444    (E.123 international format)
phoneNumber.ToString("N");               // (0114) 2726444     (E.123 national notation format)
phoneNumber.ToString("RFC3966");         // tel:+44-114-272644 (RFC3966 format)
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.14.0 72 3/28/2023
2.13.3 72 3/24/2023
2.13.2 68 3/21/2023
2.13.1 124 3/17/2023
2.13.0 122 3/14/2023
2.12.1 370 3/4/2023
2.12.0 113 3/3/2023
2.11.0 220 2/24/2023
2.10.0 1,214 12/12/2022
2.9.1 279 10/26/2022
2.9.0 234 10/26/2022
2.8.0 228 10/6/2022
2.7.0 1,272 9/9/2022
2.6.0 266 9/7/2022
2.5.0 708 6/8/2022
2.4.1 716 4/20/2022
2.4.0 345 1/13/2022
2.3.0 182 12/31/2021
2.2.1 230 11/19/2021
2.2.0 213 11/11/2021
2.1.1 281 5/21/2021
2.1.0 272 4/20/2021
2.0.0 244 3/22/2021
1.8.0 281 2/5/2021
1.7.0 277 2/2/2021
1.6.0 278 1/25/2021
1.5.0 300 1/21/2021
1.4.0 250 1/19/2021
1.3.0 268 1/15/2021
1.2.0 253 1/14/2021
1.1.0 295 1/11/2021
1.0.1 371 1/2/2021
1.0.0 283 12/31/2020

See https://github.com/TrevorPilley/phone-number-parser/releases for a summary of changes made in this release of the package.