Skip to content
On this page

Phone

Module to generate phone-related data.

imei

Generates IMEI number.

Returns: string

ts
faker.phone.imei(): string
faker.phone.imei() // => "55-786858-466342-8"
faker.phone.imei() // '13-850175-913761-7'

number

Generates a random phone number.

Parameters

NameTypeDefaultDescription
format?string

Format of the phone number. Defaults to a random phone number format.

Returns: string

ts
faker.phone.number(format?: string): string
faker.phone.number() // => "1-678-685-8466 x342"
faker.phone.number() // '961-770-7727'
faker.phone.number('501-###-###') // '501-039-841'
faker.phone.number('+48 91 ### ## ##') // '+48 91 463 61 70'

phoneFormats

Deprecated

This method is deprecated and will be removed in a future version.

Returns a random phone number format.

Returns: string

ts
faker.phone.phoneFormats(): string
faker.phone.phoneFormats() // => "1-!##-!##-#### x###"
faker.phone.phoneFormats() // '!##.!##.####'

See Also

- faker.phone.phoneNumber() - faker.definitions.phone_number.formats()

phoneNumber

Deprecated

This method is deprecated and will be removed in a future version.

Generates a random phone number.

Parameters

NameTypeDefaultDescription
format?string

Format of the phone number. Defaults to a random phone number format.

Returns: string

ts
faker.phone.phoneNumber(format?: string): string
faker.phone.phoneNumber() // => "1-678-685-8466 x342"
faker.phone.phoneNumber() // '961-770-7727'
faker.phone.phoneNumber('501-###-###') // '501-039-841'
faker.phone.phoneNumber('+48 91 ### ## ##') // '+48 91 463 61 70'

phoneNumberFormat

Deprecated

This method is deprecated and will be removed in a future version.

Returns phone number in a format of the given index from faker.definitions.phone_number.formats.

Parameters

NameTypeDefaultDescription
phoneFormatsArrayIndexnumber0

Index in the faker.definitions.phone_number.formats array.

Returns: string

ts
faker.phone.phoneNumberFormat(phoneFormatsArrayIndex: number = 0): string
faker.phone.phoneNumberFormat() // => "657-868-5846"
faker.phone.phoneNumberFormat() // '943-627-0355'
faker.phone.phoneNumberFormat(3) // '282.652.3201'

See Also

- faker.phone.phoneNumber() - faker.helpers.replaceSymbolWithNumber()

Released under the MIT License.