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;
faker.lorem.lines()
// 'Rerum quia aliquam pariatur explicabo sint minima eos.
// Voluptatem repellat consequatur deleniti qui quibusdam harum cumque.
// Enim eveniet a qui.
// Consectetur velit eligendi animi nostrum veritatis.'

faker.lorem.lines()
// 'Soluta deserunt eos quam reiciendis libero autem enim nam ut.
// Voluptate aut aut.'

faker.lorem.lines(2)
// 'Quod quas nam quis impedit aut consequuntur.
// Animi dolores aspernatur.'

faker.lorem.lines({ min: 1, max: 3 })
// 'Error dolorem natus quos eum consequatur necessitatibus.'

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;
faker.lorem.paragraph() // 'Non architecto nam unde sint. Ex tenetur dolor facere optio aut consequatur. Ea laudantium reiciendis repellendus.'
faker.lorem.paragraph(2) // 'Animi possimus nemo consequuntur ut ea et tempore unde qui. Quis corporis esse occaecati.'
faker.lorem.paragraph({ min: 1, max: 3 }) // 'Quis doloribus necessitatibus sint. Rerum accusamus impedit corporis porro.'

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;
faker.lorem.paragraphs()
// 'Beatae voluptatem dicta et assumenda fugit eaque quidem consequatur. Fuga unde provident. Id reprehenderit soluta facilis est laborum laborum. Illum aut non ut. Est nulla rem ipsa.
// Voluptatibus quo pariatur est. Temporibus deleniti occaecati pariatur nemo est molestias voluptas. Doloribus commodi et et exercitationem vel et. Omnis inventore cum aut amet.
// Sapiente deleniti et. Ducimus maiores eum. Rem dolorem itaque aliquam.'

faker.lorem.paragraphs(5)
// 'Quia hic sunt ducimus expedita quo impedit soluta. Quam impedit et ipsum optio. Unde dolores nulla nobis vero et aspernatur officiis.
// Aliquam dolorem temporibus dolores voluptatem voluptatem qui nostrum quia. Sit hic facilis rerum eius. Beatae doloribus nesciunt iste ipsum.
// Natus nam eum nulla voluptas molestiae fuga libero nihil voluptatibus. Sed quam numquam eum ipsam temporibus eaque ut et. Enim quas debitis quasi quis. Vitae et vitae.
// Repellat voluptatem est laborum illo harum sed reprehenderit aut. Quo sit et. Exercitationem blanditiis totam velit ad dicta placeat.
// Rerum non eum incidunt amet quo. Eaque laborum ut. Recusandae illo ab distinctio veritatis. Cum quis architecto ad maxime a.'

faker.lorem.paragraphs(2, '<br/>\n')
// 'Eos magnam aut qui accusamus. Sapiente quas culpa totam excepturi. Blanditiis totam distinctio occaecati dignissimos cumque atque qui officiis.<br/>
// Nihil quis vel consequatur. Blanditiis commodi deserunt sunt animi dolorum. A optio porro hic dolorum fugit aut et sint voluptas. Minima ad sed ipsa est non dolores.'

faker.lorem.paragraphs({ min: 1, max: 3 })
// 'Eum nam fugiat laudantium.
// Dignissimos tempore porro necessitatibus commodi nam.
// Veniam at commodi iste perferendis totam dolorum corporis ipsam.'

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;
faker.lorem.sentence() // 'Voluptatum cupiditate suscipit autem eveniet aut dolorem aut officiis distinctio.'
faker.lorem.sentence(5) // 'Laborum voluptatem officiis est et.'
faker.lorem.sentence({ min: 3, max: 5 }) // 'Fugiat repellendus nisi.'

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;
faker.lorem.sentences() // 'Iste molestiae incidunt aliquam possimus reprehenderit eum corrupti. Deleniti modi voluptatem nostrum ut esse.'
faker.lorem.sentences(2) // 'Maxime vel numquam quibusdam. Dignissimos ex molestias quos aut molestiae quam nihil occaecati maiores.'
faker.lorem.sentences(2, '\n')
// 'Et rerum a unde tempora magnam sit nisi.
// Et perspiciatis ipsam omnis.'
faker.lorem.sentences({ min: 1, max: 3 }) // 'Placeat ex natus tenetur repellendus repellendus iste. Optio nostrum veritatis.'

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;
faker.lorem.slug() // 'dolores-illo-est'
faker.lorem.slug(5) // 'delectus-totam-iusto-itaque-placeat'
faker.lorem.slug({ min: 1, max: 3 }) // 'illo-ratione'

text

Generates a random text based on a random lorem method.

Available since v3.1.0

Returns: string

ts
function text(): string;
faker.lorem.text() // 'Doloribus autem non quis vero quia.'
faker.lorem.text()
// 'Rerum eum reiciendis id ipsa hic dolore aut laborum provident.
// Quis beatae quis corporis veritatis corrupti ratione delectus sapiente ut.
// Quis ut dolor dolores facilis possimus tempore voluptates.
// Iure nam officia optio cumque.
// Dolor tempora iusto.'

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;
faker.lorem.word() // 'temporibus'
faker.lorem.word(5) // 'velit'
faker.lorem.word({ strategy: 'shortest' }) // 'a'
faker.lorem.word({ length: { min: 5, max: 7 }, strategy: 'fail' }) // 'quaerat'

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;
faker.lorem.words() // 'qui praesentium pariatur'
faker.lorem.words(10) // 'debitis consectetur voluptatem non doloremque ipsum autem totam eum ratione'
faker.lorem.words({ min: 1, max: 3 }) // 'tenetur error cum'

Released under the MIT License.