Adds a phoneNumberField to Payload that uses libphonenumber-js to format and validate phone numbers per country. It is enabled through a plugin in the config, with project-wide or per-field allowed countries and default country. Numbers are stored in E.164 format and returned as objects with national and international forms. Requires Payload 3 and an import map regeneration.
Phone Number Plugin for Payload CMS.
Installation
npm i payload-phone-number-plugin17
Stars
1
Forks
3
Open Issues
1 weeks ago
Last Updated
698
Weekly Downloads
v1.7.1
npm Version
247.6 KB
Unpacked Size
3
Dependencies
17+2 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 17 |
| Dec 4, 2026 | 17 |
| Dec 3, 2026 | 17 |
| Dec 2, 2026 | 17 |
| Dec 1, 2026 | 17 |
| Nov 30, 2026 | 17 |
| Nov 29, 2026 | 17 |
| Nov 28, 2026 | 17 |
| Nov 27, 2026 | 17 |
| Nov 26, 2026 | 17 |
| Nov 25, 2026 | 17 |
| Nov 24, 2026 | 17 |
| Nov 23, 2026 | 17 |
| Nov 22, 2026 | 17 |
| Nov 21, 2026 | 17 |
| Nov 20, 2026 | 17 |
| Nov 19, 2026 | 17 |
| Nov 18, 2026 | 17 |
| Nov 17, 2026 | 17 |
| Nov 16, 2026 | 17 |
| Nov 15, 2026 | 17 |
| Nov 14, 2026 | 17 |
| Nov 13, 2026 | 17 |
| Nov 12, 2026 | 17 |
| Nov 11, 2026 | 17 |
| Nov 10, 2026 | 17 |
| Nov 9, 2026 | 17 |
| Nov 8, 2026 | 17 |
| Nov 7, 2026 | 17 |
| Nov 6, 2026 | 17 |
| Nov 5, 2026 | 17 |
| Nov 4, 2026 | 16 |
| Nov 3, 2026 | 16 |
| Nov 2, 2026 | 16 |
| Nov 1, 2026 | 16 |
| Oct 31, 2026 | 16 |
| Oct 30, 2026 | 16 |
| Oct 29, 2026 | 16 |
| Oct 28, 2026 | 16 |
| Oct 27, 2026 | 16 |
| Oct 26, 2026 | 16 |
| Oct 25, 2026 | 16 |
| Oct 24, 2026 | 16 |
| Oct 23, 2026 | 16 |
| Oct 22, 2026 | 16 |
| Oct 21, 2026 | 16 |
| Oct 20, 2026 | 16 |
| Oct 19, 2026 | 16 |
| Oct 18, 2026 | 16 |
| Oct 17, 2026 | 16 |
| Oct 16, 2026 | 16 |
| Oct 15, 2026 | 16 |
| Oct 14, 2026 | 16 |
| Oct 13, 2026 | 16 |
| Oct 12, 2026 | 16 |
| Oct 11, 2026 | 16 |
| Oct 10, 2026 | 16 |
| Oct 9, 2026 | 15 |
| Oct 8, 2026 | 15 |
| Oct 7, 2026 | 15 |
| Oct 6, 2026 | 15 |
| Oct 5, 2026 | 15 |
| Oct 4, 2026 | 15 |
| Oct 3, 2026 | 15 |
| Oct 2, 2026 | 15 |
| Oct 1, 2026 | 15 |
| Sep 30, 2026 | 15 |
| Sep 29, 2026 | 15 |
| Sep 28, 2026 | 15 |
| Sep 27, 2026 | 15 |
| Sep 26, 2026 | 15 |
| Sep 25, 2026 | 15 |
| Sep 24, 2026 | 15 |
| Sep 23, 2026 | 15 |
| Sep 22, 2026 | 15 |
| Sep 21, 2026 | 15 |
| Sep 20, 2026 | 15 |
| Sep 19, 2026 | 15 |
| Sep 18, 2026 | 15 |
| Sep 17, 2026 | 15 |
| Sep 16, 2026 | 15 |
| Sep 15, 2026 | 15 |
| Sep 14, 2026 | 15 |
| Sep 13, 2026 | 15 |
| Sep 12, 2026 | 15 |
| Sep 11, 2026 | 15 |
| Sep 10, 2026 | 15 |
| Sep 9, 2026 | 15 |
| Sep 8, 2026 | 15 |
| Sep 7, 2026 | 15 |
| Sep 6, 2026 | 15 |
682+151 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 682 |
| Dec 4, 2026 | 712 |
| Dec 3, 2026 | 700 |
| Dec 2, 2026 | 628 |
| Dec 1, 2026 | 649 |
| Nov 30, 2026 | 616 |
| Nov 29, 2026 | 566 |
| Nov 28, 2026 | 692 |
| Nov 27, 2026 | 526 |
| Nov 26, 2026 | 625 |
| Nov 25, 2026 | 810 |
| Nov 24, 2026 | 805 |
| Nov 23, 2026 | 1,158 |
| Nov 22, 2026 | 1,545 |
| Nov 21, 2026 | 1,444 |
| Nov 20, 2026 | 1,562 |
| Nov 19, 2026 | 1,452 |
| Nov 18, 2026 | 1,313 |
| Nov 17, 2026 | 1,287 |
| Nov 16, 2026 | 945 |
| Nov 15, 2026 | 613 |
| Nov 14, 2026 | 650 |
| Nov 13, 2026 | 690 |
| Nov 12, 2026 | 784 |
| Nov 11, 2026 | 747 |
| Nov 10, 2026 | 765 |
| Nov 9, 2026 | 765 |
| Nov 8, 2026 | 910 |
| Nov 7, 2026 | 900 |
| Nov 6, 2026 | 863 |
| Nov 5, 2026 | 805 |
| Nov 4, 2026 | 950 |
| Nov 3, 2026 | 930 |
| Nov 2, 2026 | 965 |
| Nov 1, 2026 | 922 |
| Oct 31, 2026 | 894 |
| Oct 30, 2026 | 796 |
| Oct 29, 2026 | 692 |
| Oct 28, 2026 | 452 |
| Oct 27, 2026 | 454 |
| Oct 26, 2026 | 410 |
| Oct 25, 2026 | 221 |
| Oct 24, 2026 | 126 |
| Oct 23, 2026 | 72 |
| Oct 22, 2026 | 127 |
| Oct 21, 2026 | 212 |
| Oct 20, 2026 | 211 |
| Oct 19, 2026 | 206 |
| Oct 18, 2026 | 197 |
| Oct 17, 2026 | 184 |
| Oct 16, 2026 | 204 |
| Oct 15, 2026 | 174 |
| Oct 14, 2026 | 154 |
| Oct 13, 2026 | 164 |
| Oct 12, 2026 | 172 |
| Oct 11, 2026 | 255 |
| Oct 10, 2026 | 294 |
| Oct 9, 2026 | 321 |
| Oct 8, 2026 | 321 |
| Oct 7, 2026 | 315 |
| Oct 6, 2026 | 322 |
| Oct 5, 2026 | 322 |
| Oct 4, 2026 | 273 |
| Oct 3, 2026 | 236 |
| Oct 2, 2026 | 227 |
| Oct 1, 2026 | 416 |
| Sep 30, 2026 | 385 |
| Sep 29, 2026 | 385 |
| Sep 28, 2026 | 394 |
| Sep 27, 2026 | 459 |
| Sep 26, 2026 | 466 |
| Sep 25, 2026 | 446 |
| Sep 24, 2026 | 257 |
| Sep 23, 2026 | 255 |
| Sep 22, 2026 | 265 |
| Sep 21, 2026 | 255 |
| Sep 20, 2026 | 185 |
| Sep 19, 2026 | 163 |
| Sep 18, 2026 | 213 |
| Sep 17, 2026 | 242 |
| Sep 16, 2026 | 270 |
| Sep 15, 2026 | 278 |
| Sep 14, 2026 | 320 |
| Sep 13, 2026 | 341 |
| Sep 12, 2026 | 374 |
| Sep 11, 2026 | 386 |
| Sep 10, 2026 | 392 |
| Sep 9, 2026 | 414 |
| Sep 8, 2026 | 515 |
| Sep 7, 2026 | 559 |
| Sep 6, 2026 | 531 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/909766798-root)<a href="https://payloaddirectory.dev/plugins/909766798-root"><img src="https://payloaddirectory.dev/badge/909766798-root.svg" alt="Payload Directory"></a>README
This Payload CMS plugin uses libphonenumber-js to format and validate phone numbers.

Install the payload-phone-number-plugin package into your project
pnpm install payload-phone-number-plugin
Add the plugin to your Payload Config:
import { phoneNumberPlugin } from 'payload-phone-number-plugin';
export const config = buildConfig({
plugins: [
phoneNumberPlugin(),
]
});
Then you can use the phone number field:
import { phoneNumberField } from 'payload-phone-number-plugin';
const Employees: CollectionConfig = {
slug: 'employees',
fields: [
phoneNumberField({
name: 'phoneNumber',
label: 'Phone Number',
required: true,
}),
]
};
[!NOTE] Remember to update your importMap with
generate:importmapsince this plugin adds a custom component
| Name | Type | Required | Description |
|---|---|---|---|
allowedCountries | RegionCode[] | false | Restricts every phoneNumberField in the project to these country codes. Individual fields can narrow further but cannot allow countries outside this list. |
defaultCountry | RegionCode | false | Project-wide default country. Field-level defaultCountry overrides this. Type-narrowed by allowedCountries. |
admin.cellDisplayFormat | 'e164' | 'national' | 'international' | false | Project-wide default for admin.cellDisplayFormat. Field-level value overrides this. |
admin.countryPrefixDisplayFormat | 'flagEmoji' | 'callingCode' | 'flagEmojiAndCallingCode' | false | Project-wide default for admin.countryPrefixDisplayFormat. Field-level value overrides this. |
phoneNumberPlugin({
allowedCountries: ['NO', 'SE', 'DK', 'US'],
defaultCountry: 'NO',
})
Field-level values override these defaults. defaultCountry and field-level allowedCountries are constrained to a subset of the plugin's allowedCountries.
[!NOTE] Run
payload generate:typesfor the type narrowing to take effect.
| Name | Type | Required | Description | Default |
|---|---|---|---|---|
defaultCountry | RegionCode | false | The default country region code for the field (ISO 3166-1 alpha-2) | 'US' |
allowedCountries | RegionCode[] | false | Array of allowed country codes. If specified, restricts user selection to these countries only | |
admin.cellDisplayFormat | 'e164' | 'national' | 'international' | false | The format to display phone numbers in table cells | 'international' |
admin.countryPrefixDisplayFormat | 'flagEmoji' | 'callingCode' | 'flagEmojiAndCallingCode' | false | The format to display the country prefix next to the field input | 'flagEmojiAndCallingCode' |
phoneNumberField({
name: 'phoneNumber',
label: 'Phone Number',
defaultCountry: 'NO', // Norway will be pre-selected
})
phoneNumberField({
name: 'phoneNumber',
label: 'Phone Number',
allowedCountries: ['NO', 'US', 'SE'], // Only these countries will be selectable
})
phoneNumberField({
name: 'phoneNumber',
label: 'Phone Number',
defaultCountry: 'NO', // Norway will be pre-selected
allowedCountries: ['NO', 'US', 'SE'], // Only these countries will be selectable
})
phoneNumberField({
name: 'phoneNumber',
label: 'Phone Number',
admin: {
cellDisplayFormat: 'e164', // Display as +4712345678 in table cells
},
})
phoneNumberField({
name: 'phoneNumber',
label: 'Phone Number',
admin: {
countryPrefixDisplayFormat: 'callingCode', // Display only +47 (no flag emoji)
},
})
When creating or updating documents, pass the phone number as an E.164 string directly. Phone numbers are stored in E.164 format in the database.
The field will handle parsing and validation so it won't save unless it's a valid phone number for that field.
await payload.create({
collection: 'employees',
data: {
phoneNumber: '+4712345678'
}
})
await fetch('http://localhost:3000/api/employees', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
phoneNumber: '+4712345678'
})
})
[!NOTE] You cannot pass a phone number object, only E.164 strings are accepted.
When using payload.find or database queries, use the E.164 format:
const employees = await payload.find({
collection: 'employees',
where: {
phoneNumber: {
equals: '+4712345678'
}
}
})
The same applies when using the REST API.
The field is typed as string | PhoneNumber, similar to Payload's relationship fields with depth.
This is because phone numbers are stored as strings in the database but are transformed into objects when you read them using libphonenumber.
export interface PhoneNumber {
e164: string;
regionCode: string;
callingCode: string;
national: string;
international: string;
}
export interface Employee {
phoneNumber: string | PhoneNumber;
}
Example response:
{
"phoneNumber": {
"e164": "+4712345678",
"regionCode": "NO",
"callingCode": "+47",
"national": "12 34 56 78",
"international": "+47 12 34 56 78"
}
}
If you need to access the raw phone number value you can use context when you query:
const employees = await payload.find({
collection: 'employees',
where: {
phoneNumber: {
equals: '+4712345678'
}
},
context: {
phoneNumberPluginReturnRawValue: true,
},
})
Example response:
{
"phoneNumber": "+4712345678"
}
A region code is an ISO 3166-1 alpha-2 code.
List of all valid region codes can be found here: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements
payload better fields plugin
Improved admin panel fields for slugs, numbers, patterns, ranges, colours, phones, alerts and dates
554.2k/wk294v3
payload mask plugin
Input masking for Payload text fields using IMask
359/wk17v1 v2
payload fields
Field factories and admin components for Unicode slugs, Jalali dates, integer money and Iranian identity data
75230/wk3v3
heading field
Field wrapper that lets editors choose the h1–h6 tag for text, textarea, or rich text headings
62156/wk16v3
payload google map autocomplete places
Google Places autocomplete field that stores a picked location and its coordinates
5542/wk28v2
payload icon picker
Icon picker field for the Payload admin with adapters for Lucide, Tabler, Heroicons, Phosphor and more
53243/wk1v3