Internet

Module to generate internet related entries.

Avatar

Returns a random avatar url.

Returns: string

faker.internet.avatar(): string
faker.internet.avatar() // => "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHir...
faker.internet.avatar()
// 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg'

Color

Generates a random css hex color code in aesthetically pleasing color palette.

Based on http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette

Parameters

NameTypeDefaultDescription
redBasenumber0

The optional base red in range between 0 and 255.

greenBasenumber0

The optional base green in range between 0 and 255.

blueBasenumber0

The optional base blue in range between 0 and 255.

Returns: string

faker.internet.color(redBase: number = 0, greenBase: number = 0, blueBase: number = 0): string
faker.internet.color() // => "#464c5b"
faker.internet.color() // '#30686e'
faker.internet.color(100, 100, 100) // '#4e5f8b'

Domain Name

Generates a random domain name.

Returns: string

faker.internet.domainName(): string
faker.internet.domainName() // => "muddy-neuropathologist.net"
faker.internet.domainName() // 'slow-timer.info'

Domain Suffix

Returns a random domain suffix.

Returns: string

faker.internet.domainSuffix(): string
faker.internet.domainSuffix() // => "name"
faker.internet.domainSuffix() // 'com'
faker.internet.domainSuffix() // 'name'

Domain Word

Generates a random domain word.

Returns: string

faker.internet.domainWord(): string
faker.internet.domainWord() // => "muddy-neuropathologist"
faker.internet.domainWord() // 'close-reality'
faker.internet.domainWord() // 'weird-cytoplasm'

Email

Generates an email address using the given person's name as base.

Parameters

NameTypeDefaultDescription
firstName?string

The optional first name to use. If not specified, a random one will be chosen.

lastName?string

The optional last name to use. If not specified, a random one will be chosen.

provider?string

The mail provider domain to use. If not specified, a random free mail provider will be chosen.

options?{ ... }{ allowSpecialCharacters: false }

The options to use.

options.allowSpecialCharacters?booleanfalse

Whether special characters such as .!#$%&'*+-/=?^_`{|}~ should be included in the email address.

Returns: string

faker.internet.email(firstName?: string, lastName?: string, provider?: string, options?: {
  allowSpecialCharacters: boolean
} = { allowSpecialCharacters: false }): string
faker.internet.email() // => "Larry_Ratke85@yahoo.com"
faker.internet.email() // 'Kassandra4@hotmail.com'
faker.internet.email('Jeanne', 'Doe') // 'Jeanne63@yahoo.com'
faker.internet.email('Jeanne', 'Doe', 'example.fakerjs.dev') // 'Jeanne_Doe88@example.fakerjs.dev'
faker.internet.email('Jeanne', 'Doe', 'example.fakerjs.dev', { allowSpecialCharacters: true }) // 'Jeanne%Doe88@example.fakerjs.dev'

Emoji

Generates a random emoji.

Parameters

NameTypeDefaultDescription
options{ ... }{}

Options object.

options.types?readonly EmojiType[]

A list of the emoji types that should be used.

Returns: string

faker.internet.emoji(options: {
  types: readonly EmojiType[]
} = {}): string
faker.internet.emoji() // => "💺"
faker.internet.emoji() // '🥰'
faker.internet.emoji({ types: ['food', 'nature'] }) // '🥐'

Example Email

Generates an email address using an example mail provider using the given person's name as base.

Parameters

NameTypeDefaultDescription
firstName?string

The optional first name to use. If not specified, a random one will be chosen.

lastName?string

The optional last name to use. If not specified, a random one will be chosen.

options?{ ... }{ allowSpecialCharacters: false }

The options to use.

options.allowSpecialCharacters?booleanfalse

Whether special characters such as .!#$%&'*+-/=?^_`{|}~ should be included in the email address.

Returns: string

faker.internet.exampleEmail(firstName?: string, lastName?: string, options?: {
  allowSpecialCharacters: boolean
} = { allowSpecialCharacters: false }): string
faker.internet.exampleEmail() // => "Larry_Ratke85@example.com"
faker.internet.exampleEmail() // 'Helmer.Graham23@example.com'
faker.internet.exampleEmail('Jeanne', 'Doe') // 'Jeanne96@example.net'
faker.internet.exampleEmail('Jeanne', 'Doe', { allowSpecialCharacters: true }) // 'Jeanne%Doe88@example.com'

Http Method

Returns a random http method.

Can be either of the following:

  • GET
  • POST
  • PUT
  • DELETE
  • PATCH

Returns: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT'

faker.internet.httpMethod(): "GET" | "POST" | "PUT" | "DELETE" | "PATCH"
faker.internet.httpMethod() // => "PUT"
faker.internet.httpMethod() // 'PATCH'

Ip

Generates a random IPv4 address.

Returns: string

faker.internet.ip(): string
faker.internet.ip() // => "140.151.183.216"
faker.internet.ip() // '245.108.222.0'

Ipv4

Generates a random IPv4 address.

Returns: string

faker.internet.ipv4(): string
faker.internet.ipv4() // => "140.151.183.216"
faker.internet.ipv4() // '245.108.222.0'

Ipv6

Generates a random IPv6 address.

Returns: string

faker.internet.ipv6(): string
faker.internet.ipv6() // => "89bd:9d8d:69a6:74e0:f467:cc87:96ed:151a"
faker.internet.ipv6() // '269f:1230:73e3:318d:842b:daab:326d:897b'

Mac

Generates a random mac address.

Parameters

NameTypeDefaultDescription
sep?string':'

The optional separator to use. Can be either ':', '-' or ''.

Returns: string

faker.internet.mac(sep?: string = ':'): string
faker.internet.mac() // => "89:bd:9d:8d:69:a6"
faker.internet.mac() // '32:8e:2e:09:c6:05'

Password

Generates a random password.

Parameters

NameTypeDefaultDescription
lennumber15

The length of the password to generate.

memorablebooleanfalse

Whether the generated password should be memorable.

patternRegExp/\w/

The pattern that all chars should match should match. This option will be ignored, if memorable is true.

prefixstring''

The prefix to use.

Returns: string

faker.internet.password(len: number = 15, memorable: boolean = false, pattern: RegExp = /\w/, prefix: string = ''): string
faker.internet.password() // => "UYdqZrTqIEJuENl"
faker.internet.password() // '89G1wJuBLbGziIs'
faker.internet.password(20) // 'aF55c_8O9kZaPOrysFB_'
faker.internet.password(20, true) // 'lawetimufozujosodedi'
faker.internet.password(20, true, /[A-Z]/) // 'HMAQDFFYLDDUTBKVNFVS'
faker.internet.password(20, true, /[A-Z]/, 'Hello ') // 'Hello IREOXTDWPERQSB'

Port

Generates a random port number.

Returns: number

faker.internet.port(): number
faker.internet.port() // => 35967
faker.internet.port() // '9414'

Protocol

Returns a random web protocol. Either http or https.

Returns: 'http' | 'https'

faker.internet.protocol(): "http" | "https"
faker.internet.protocol() // => "https"
faker.internet.protocol() // 'http'
faker.internet.protocol() // 'https'

Url

Generates a random url.

Returns: string

faker.internet.url(): string
faker.internet.url() // => "https://optimistic-rabbi.org"
faker.internet.url() // 'https://remarkable-hackwork.info'

User Agent

Generates a random user agent string.

Returns: string

faker.internet.userAgent(): string
faker.internet.userAgent() // => "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT ...
faker.internet.userAgent()
// 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_8_8)  AppleWebKit/536.0.2 (KHTML, like Gecko) Chrome/27.0.849.0 Safari/536.0.2'

User Name

Generates a username using the given person's name as base.

Parameters

NameTypeDefaultDescription
firstName?string

The optional first name to use. If not specified, a random one will be chosen.

lastName?string

The optional last name to use. If not specified, a random one will be chosen.

Returns: string

faker.internet.userName(firstName?: string, lastName?: string): string
faker.internet.userName() // => "Katelynn_Medhurst60"
faker.internet.userName() // 'Nettie_Zboncak40'
faker.internet.userName('Jeanne', 'Doe') // 'Jeanne98'