Skip to content

Word

Module to return various types of words.

adjective

Returns a random adjective.

Available since v6.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function adjective(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.adjective() // 'negligible'
faker.word.adjective(5) // 'short'
faker.word.adjective(100) // 'perky'
faker.word.adjective({ strategy: 'shortest' }) // 'mad'
faker.word.adjective({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'likable'

adverb

Returns a random adverb.

Available since v6.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function adverb(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.adverb() // 'often'
faker.word.adverb(5) // 'sadly'
faker.word.adverb(100) // 'promptly'
faker.word.adverb({ strategy: 'shortest' }) // 'not'
faker.word.adverb({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'likely'

conjunction

Returns a random conjunction.

Available since v6.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function conjunction(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.conjunction() // 'provided'
faker.word.conjunction(5) // 'which'
faker.word.conjunction(100) // 'supposing'
faker.word.conjunction({ strategy: 'shortest' }) // 'or'
faker.word.conjunction({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'since'

interjection

Returns a random interjection.

Available since v6.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function interjection(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.interjection() // 'ugh'
faker.word.interjection(5) // 'yahoo'
faker.word.interjection(100) // 'eek'
faker.word.interjection({ strategy: 'shortest' }) // 'aw'
faker.word.interjection({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'boohoo'

noun

Returns a random noun.

Available since v6.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function noun(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.noun() // 'mantua'
faker.word.noun(5) // 'slide'
faker.word.noun(100) // 'newsletter'
faker.word.noun({ strategy: 'shortest' }) // 'ad'
faker.word.noun({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'jungle'

preposition

Returns a random preposition.

Available since v6.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function preposition(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.preposition() // 'like'
faker.word.preposition(5) // 'round'
faker.word.preposition(100) // 'next'
faker.word.preposition({ strategy: 'shortest' }) // 'a'
faker.word.preposition({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'circa'

sample

Returns a random word, that can be an adjective, adverb, conjunction, interjection, noun, preposition, or verb.

Available since v8.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function sample(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.sample() // 'jealous'
faker.word.sample(5) // 'weird'

verb

Returns a random verb.

Available since v6.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The expected length of the word or the options to use.

options.length?number | { min: number; max: number; }

The expected length of the word.

options.strategy?'fail' | 'closest' | 'shortest' | 'longest' | 'any-length''any-length'

The strategy to apply when no words with a matching length are found.

Available error handling strategies:

  • fail: Throws an error if no words with the given length are found.
  • shortest: Returns any of the shortest words.
  • closest: Returns any of the words closest to the given length.
  • longest: Returns any of the longest words.
  • any-length: Returns a word with any length.

Returns: string

ts
function verb(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.word.verb() // 'nauseate'
faker.word.verb(5) // 'slump'
faker.word.verb(100) // 'pause'
faker.word.verb({ strategy: 'shortest' }) // 'pip'
faker.word.verb({ length: { min: 5, max: 7 }, strategy: "fail" }) // 'implode'

words

Returns a random string containing some words separated by spaces.

Available since v8.0.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

The optional options object or the number of words to return.

options.count?number | { min: number; max: number; }{ min: 1, max: 3 }

The number of words to return.

Returns: string

ts
function words(
  options:
    | number
    | {
        count?:
          | number
          | {
              min: number;
              max: number;
            };
      } = {}
): string;

Examples

ts
faker.word.words() // 'tapioca blaring'
faker.word.words(5) // 'the mismatch plagiarise past interestingly'
faker.word.words({ count: 5 }) // 'reassuringly amongst wedge colorfully orientate'
faker.word.words({ count: { min: 5, max: 10 } }) // 'ceramic yuck supposing friendly serpentine if'

Released under the MIT License.