Skip to content

Lorem

Module to generate random texts and words.

Overview

Generate dummy content using traditional faux-Latin lorem ipsum (in other locales to en, alternative words may be used).

In order of increasing size you can generate a single word(), multiple words(), a sentence(), multiple sentences(), lines() separated by newlines, one paragraph(), or multiple paragraphs().

The generic text() method can be used to generate some text between one sentence and multiple paragraphs, while slug() generates an URL-friendly hyphenated string.

lines

Generates the given number lines of lorem separated by '\n'.

Available since v3.1.0

Parameters

NameTypeDefaultDescription
lineCountnumber | { ... }{ min: 1, max: 5 }

The number of lines to generate. Defaults to a random number between 1 and 5.

lineCount.maxnumber

The maximum number of lines to generate.

lineCount.minnumber

The minimum number of lines to generate.

Returns: string

ts
function lines(
  lineCount:
    | number
    | {
        min: number;
        max: number;
      } = { min: 1, max: 5 }
): string;

Examples

ts
faker.lorem.lines()
// 'Pax impedit curriculum sint debitis vallum vix credo.
// Eveniet minus vespillo aeneus alias accusator tristis tergo usus.
// Thermae deinde termes angustus rerum arbitro vinco enim cuppedia celo.'

faker.lorem.lines()
// 'Minus accusamus quae perspiciatis provident villa.
// Contigo debilito subiungo adulescens sopor spargo bene aperiam.
// Convoco molestiae decens voveo ambitus.
// Arx solitudo catena deleniti.'

faker.lorem.lines(2)
// 'Articulus amor sollicito aptus.
// Corporis trado alter tum.'

faker.lorem.lines({ min: 1, max: 3 }) // 'Delicate voluptatibus pecco tactus adflicto cimentarius animi clementia angustus cometes.'

paragraph

Generates a paragraph with the given number of sentences.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
sentenceCountnumber | { ... }3

The number of sentences to generate.

sentenceCount.maxnumber

The maximum number of sentences to generate.

sentenceCount.minnumber

The minimum number of sentences to generate.

Returns: string

ts
function paragraph(
  sentenceCount:
    | number
    | {
        min: number;
        max: number;
      } = 3
): string;

Examples

ts
faker.lorem.paragraph() // 'Sumo pax impedit curriculum sint debitis vallum. Credo textilis eveniet minus vespillo aeneus alias accusator tristis tergo. Volutabrum thermae deinde termes angustus rerum arbitro vinco enim.'
faker.lorem.paragraph(2) // 'Celo teres defleo minus accusamus quae. Provident villa statim contigo debilito subiungo adulescens.'
faker.lorem.paragraph({ min: 1, max: 3 }) // 'Bene aperiam comedo convoco molestiae decens voveo ambitus. Arx solitudo catena deleniti. Articulus amor sollicito aptus.'

paragraphs

Generates the given number of paragraphs.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
paragraphCountnumber | { ... }3

The number of paragraphs to generate.

paragraphCount.maxnumber

The maximum number of paragraphs to generate.

paragraphCount.minnumber

The minimum number of paragraphs to generate.

separatorstring'\n'

The separator to use.

Returns: string

ts
function paragraphs(
  paragraphCount:
    | number
    | {
        min: number;
        max: number;
      } = 3,
  separator: string = '\n'
): string;

Examples

ts
faker.lorem.paragraphs()
// 'Sumo pax impedit curriculum sint debitis vallum. Credo textilis eveniet minus vespillo aeneus alias accusator tristis tergo. Volutabrum thermae deinde termes angustus rerum arbitro vinco enim.
// Celo teres defleo minus accusamus quae. Provident villa statim contigo debilito subiungo adulescens. Spargo bene aperiam comedo convoco molestiae decens voveo.
// Bellicus arx solitudo. Deleniti caries articulus amor sollicito. Auxilium corporis trado alter.'

faker.lorem.paragraphs(5)
// 'Alo voluptatibus delicate voluptatibus pecco tactus adflicto cimentarius animi. Angustus cometes cupio advoco stultus. Cena eos aliquid nemo vetus comis sopor.
// Sumptus clam auctus occaecati. Tricesimus abeo spiritus. Tabesco vivo carpo nemo omnis.
// Cado viridis dedecor tyrannus subnecto coadunatio torqueo. Uxor nobis uxor stultus surgo desino. Sequi curriculum pecto accusantium cogito solutio clam quae curto appositus.
// Molestiae officiis natus solitudo solio. Vel corona debeo vapulus timidus succurro. Verto summopere vulticulus.
// Ustilo ascisco possimus anser. Timor modi cum aegrus subiungo defetiscor suppono usitas voluptates. Absum contigo sustineo astrum eligendi adopto aveho accusamus textus.'

faker.lorem.paragraphs(2, '<br/>\n')
// 'Coniuratio vestrum succurro addo. Quas neque capio victus. Facilis officia sustineo color cubicularis bellum audentia.<br/>
// Tactus depraedor calcar caterva adsuesco damno color subito crapula attero. Aegre spoliatio defetiscor. Vel vulariter bis somnus celer accusator tempora.'

faker.lorem.paragraphs({ min: 1, max: 3 }) // 'Odio tripudio quo uter certus theologus. Viridis stips bibo vinitor. Catena benigne eaque acies beatus currus corrumpo delectus.'

sentence

Generates a space separated list of words beginning with a capital letter and ending with a period.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
wordCountnumber | { ... }{ min: 3, max: 10 }

The number of words, that should be in the sentence. Defaults to a random number between 3 and 10.

wordCount.maxnumber

The maximum number of words to generate.

wordCount.minnumber

The minimum number of words to generate.

Returns: string

ts
function sentence(
  wordCount:
    | number
    | {
        min: number;
        max: number;
      } = { min: 3, max: 10 }
): string;

Examples

ts
faker.lorem.sentence() // 'Sumo pax impedit curriculum sint debitis vallum.'
faker.lorem.sentence(5) // 'Vix credo textilis eveniet minus.'
faker.lorem.sentence({ min: 3, max: 5 }) // 'Aeneus alias accusator tristis tergo.'

sentences

Generates the given number of sentences.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
sentenceCountnumber | { ... }{ min: 2, max: 6 }

The number of sentences to generate. Defaults to a random number between 2 and 6.

sentenceCount.maxnumber

The maximum number of sentences to generate.

sentenceCount.minnumber

The minimum number of sentences to generate.

separatorstring' '

The separator to add between sentences.

Returns: string

ts
function sentences(
  sentenceCount:
    | number
    | {
        min: number;
        max: number;
      } = { min: 2, max: 6 },
  separator: string = ' '
): string;

Examples

ts
faker.lorem.sentences() // 'Pax impedit curriculum sint debitis vallum vix credo. Eveniet minus vespillo aeneus alias accusator tristis tergo usus. Thermae deinde termes angustus rerum arbitro vinco enim cuppedia celo. Defleo minus accusamus quae perspiciatis provident villa statim contigo.'
faker.lorem.sentences(2) // 'Subiungo adulescens sopor spargo bene aperiam. Convoco molestiae decens voveo ambitus.'
faker.lorem.sentences(2, '\n')
// 'Arx solitudo catena deleniti.
// Articulus amor sollicito aptus.'
faker.lorem.sentences({ min: 1, max: 3 }) // 'Trado alter tum alo voluptatibus.'

slug

Generates a slugified text consisting of the given number of hyphen separated words.

Available since v4.0.0

Parameters

NameTypeDefaultDescription
wordCountnumber | { ... }3

The number of words to generate.

wordCount.maxnumber

The maximum number of words to generate.

wordCount.minnumber

The minimum number of words to generate.

Returns: string

ts
function slug(
  wordCount:
    | number
    | {
        min: number;
        max: number;
      } = 3
): string;

Examples

ts
faker.lorem.slug() // 'inflammatio-sumo-pax'
faker.lorem.slug(5) // 'impedit-curriculum-sint-debitis-vallum'
faker.lorem.slug({ min: 1, max: 3 }) // 'credo-textilis-eveniet'

text

Generates a random text based on a random lorem method.

Available since v3.1.0

Returns: string

ts
function text(): string;

Examples

ts
faker.lorem.text() // 'Pax impedit curriculum sint debitis vallum vix credo. Eveniet minus vespillo aeneus alias accusator tristis tergo usus. Thermae deinde termes angustus rerum arbitro vinco enim cuppedia celo.'
faker.lorem.text()
// 'Minus accusamus quae perspiciatis provident villa. Contigo debilito subiungo adulescens sopor spargo bene aperiam. Convoco molestiae decens voveo ambitus.
// Arx solitudo catena deleniti. Articulus amor sollicito aptus. Corporis trado alter tum.
// Voluptatibus delicate voluptatibus. Tactus adflicto cimentarius animi clementia angustus cometes. Advoco stultus minima cena eos aliquid.'

word

Generates a word of a specified length.

Available since v3.1.0

Parameters

NameTypeDefaultDescription
optionsnumber | { ... }{}

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

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

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 word(
  options:
    | number
    | {
        length?:
          | number
          | {
              min: number;
              max: number;
            };
        strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
      } = {}
): string;

Examples

ts
faker.lorem.word() // 'inflammatio'
faker.lorem.word(5) // 'teneo'
faker.lorem.word({ strategy: 'shortest' }) // 'a'
faker.lorem.word({ length: { min: 5, max: 7 }, strategy: 'fail' }) // 'pauci'

words

Generates a space separated list of words.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
wordCountnumber | { ... }3

The number of words to generate.

wordCount.maxnumber

The maximum number of words to generate.

wordCount.minnumber

The minimum number of words to generate.

Returns: string

ts
function words(
  wordCount:
    | number
    | {
        min: number;
        max: number;
      } = 3
): string;

Examples

ts
faker.lorem.words() // 'inflammatio sumo pax'
faker.lorem.words(10) // 'impedit curriculum sint debitis vallum vix credo textilis eveniet minus'
faker.lorem.words({ min: 1, max: 3 }) // 'aeneus alias accusator'

Released under the MIT License.