The one-liner for every stack
Find your environment, copy the call, done. The right-hand column is what each snippet returns.
| Environment | Tool / method | One-liner | Returns |
|---|---|---|---|
| JavaScript / Node | lorem-ipsum | new LoremIpsum().generateParagraphs(3) | 3 paragraphs (string) |
| JavaScript / Node | @faker-js/faker | faker.lorem.paragraphs(3) | 3 paragraphs (string) |
| Python | lorem | lorem.get_paragraph() | 1 paragraph (string) |
| Python | Faker | Faker().paragraph() | 1 paragraph (string) |
| Java | datafaker / javafaker | faker.lorem().paragraph() | 1 paragraph (string) |
| C# / .NET | Bogus | new Faker().Lorem.Paragraph() | 1 paragraph (string) |
| Ruby | faker gem | Faker::Lorem.paragraph | 1 paragraph (string) |
| HTML (VS Code) | Emmet (built in) | type lorem100 → Tab, or p*3>lorem20 | 100 words / 3 <p> blocks |
| Figma | "Lorem ipsum" / "Content Reel" plugin | run plugin on a selected text layer | filler text in the layer |
| CSS | no native generator | use Emmet in the HTML, or ::after { content: "…" } with static text | static placeholder |
| Any (no dependency) | Bacon Ipsum API | fetch('https://baconipsum.com/api/?type=meat-and-filler¶s=3&format=json') | JSON array of paragraphs |
Which should you use? If you only need body text, reach for the dedicated lorem-ipsum package (JS) or lorem (Python) — smallest surface, most control over counts. If you are seeding a database or mocking records, use faker everywhere: it gives you Lorem Ipsum and realistic names, emails, and dates from one dependency. If you are laying out a static page, skip the library entirely and let Emmet expand lorem inline. Only reach for an API when adding a dependency isn't worth it for a one-off.
Why automate it at all
Manual placeholder text is tedious and easy to get wrong. Developers constantly need dummy content — to test that a card grows gracefully with a long title, to demo a feature, or to show a layout to stakeholders before real copy exists. Generating it in code removes the copy-paste loop and makes the output consistent: every mockup and test fixture uses the same shape of text, so layout bugs surface early and the same seed reproduces the same content on demand.
The payoff compounds in testing and seeding, where you need dozens or hundreds of records. Hand-writing those is a waste; a single faker.lorem.paragraphs() in a loop fills a table.
JavaScript and Node.js
The lorem-ipsum package is the focused choice. Note the important detail most snippets get wrong: the package exports a LoremIpsum class you must instantiate — you cannot call generateParagraphs on the module directly.
const { LoremIpsum } = require('lorem-ipsum');
const lorem = new LoremIpsum({
sentencesPerParagraph: { max: 8, min: 4 },
wordsPerSentence: { max: 16, min: 4 }
});
console.log(lorem.generateParagraphs(3)); // 3 paragraphs
console.log(lorem.generateSentences(5)); // 5 sentences
console.log(lorem.generateWords(20)); // 20 words
If you prefer a one-shot call with no instance, use the standalone loremIpsum() function:
const { loremIpsum } = require('lorem-ipsum');
const text = loremIpsum({
count: 3, // number of units
units: 'paragraphs', // 'paragraphs' | 'sentences' | 'words'
format: 'plain' // 'plain' | 'html'
});
console.log(text);
For React, generate the content wherever you build the props — at build time for static demos, or in a memoized value at runtime:
import { loremIpsum } from 'lorem-ipsum';
export default function BlogPostDemo() {
const content = loremIpsum({ count: 5, units: 'paragraphs' });
return (
<article>
<h1>Blog Post Title</h1>
<p>{content}</p>
</article>
);
}
When you need more than body text — names, emails, addresses for realistic records — use @faker-js/faker (the maintained successor to the abandoned original faker). Its Lorem Ipsum lives under faker.lorem.*:
const { faker } = require('@faker-js/faker');
// Lorem Ipsum
const paragraph = faker.lorem.paragraphs(3);
const sentence = faker.lorem.sentence();
const word = faker.lorem.word();
// Realistic fake data
const name = faker.person.fullName();
const email = faker.internet.email();
const address = faker.location.streetAddress(); // note: streetAddress, not fullAddress
console.log(paragraph, name, email, address);
Python
The lorem package generates filler text with a simple API. Use the get_* functions, which return strings directly:
import lorem
print(lorem.get_paragraph()) # one paragraph
print(lorem.get_sentence()) # one sentence
print(lorem.get_word()) # one word
print(lorem.get_text()) # a full block of several paragraphs
For realistic records, Python's Faker mirrors the JS library:
from faker import Faker
fake = Faker()
# Lorem Ipsum
print(fake.paragraph()) # one paragraph
print(fake.sentence()) # one sentence
print(fake.text(max_nb_chars=300)) # ~300 chars of text
print(fake.paragraphs(nb=3)) # list of 3 paragraph strings
# Realistic fake data
print(fake.name())
print(fake.email())
print(fake.address())
For Django, wrap Faker in a template tag so designers can drop placeholder text into templates:
# templatetags/lorem_tags.py
from django import template
from faker import Faker
register = template.Library()
fake = Faker()
@register.simple_tag
def lorem_paragraphs(count=3):
return '\n\n'.join(fake.paragraphs(nb=count))
{% load lorem_tags %}
<div>{% lorem_paragraphs 3 %}</div>
Other languages
Every major ecosystem has a faker-style library, and the Lorem Ipsum call looks nearly identical across them:
// Java — Datafaker (the maintained fork of JavaFaker)
Faker faker = new Faker();
System.out.println(faker.lorem().paragraph());
System.out.println(faker.lorem().sentence());
// C# / .NET — Bogus
var faker = new Faker();
Console.WriteLine(faker.Lorem.Paragraph());
Console.WriteLine(faker.Lorem.Sentence());
# Ruby — faker gem
require 'faker'
puts Faker::Lorem.paragraph
puts Faker::Lorem.sentence
puts Faker::Lorem.word
No dependency? Use an API
If you don't want to add a package, call a public generator. Bacon Ipsum returns JSON and is dependency-free from the browser or Node:
fetch('https://baconipsum.com/api/?type=meat-and-filler¶s=3&format=json')
.then((response) => response.json())
.then((paragraphs) => console.log(paragraphs.join('\n\n')))
.catch((error) => console.error(error));
The trade-offs are real: a network call adds latency, fails offline or in a sandboxed CI runner, and a third-party service can rate-limit or shut down. (The once-popular quotable.io random-quote API, for example, has gone offline — a reminder not to hard-wire a demo to someone else's uptime.) For anything that runs repeatedly, a local library is the safer bet; save APIs for one-off content.
Seeding tests and databases
Placeholder generation shines when you need many records. Seed the generator first if you want the same output every run — critical for snapshot tests that would otherwise flap.
// Jest — deterministic fixtures with @faker-js/faker
const { faker } = require('@faker-js/faker');
describe('Blog component', () => {
beforeEach(() => faker.seed(123)); // reproducible output
it('renders a post with placeholder content', () => {
const post = {
title: faker.lorem.sentence(),
content: faker.lorem.paragraphs(3),
author: faker.person.fullName()
};
expect(post.content).toBeTruthy();
});
});
// Sequelize seeder
const { LoremIpsum } = require('lorem-ipsum');
const lorem = new LoremIpsum();
module.exports = {
async up(queryInterface) {
const rows = Array.from({ length: 2 }, (_, i) => ({
title: `Demo Post ${i + 1}`,
content: lorem.generateParagraphs(5),
createdAt: new Date(),
updatedAt: new Date()
}));
await queryInterface.bulkInsert('posts', rows);
}
};
# factory_boy — Django model factory
import factory
from faker import Faker
from .models import BlogPost
fake = Faker()
class BlogPostFactory(factory.django.DjangoModelFactory):
class Meta:
model = BlogPost
title = factory.Faker('sentence')
content = factory.LazyFunction(lambda: '\n\n'.join(fake.paragraphs(nb=5)))
author = factory.Faker('name')
Building a custom generator
When you need structured placeholder objects — a blog post, a product — wrap a generator in a small class. (The version of this pattern that circulates online often has a broken constructor; here is one that actually runs.)
const { LoremIpsum } = require('lorem-ipsum');
class PlaceholderFactory {
constructor() {
this.lorem = new LoremIpsum();
}
blogPost() {
return {
title: this.lorem.generateSentences(1).trim(),
excerpt: this.lorem.generateSentences(2).trim(),
content: this.lorem.generateParagraphs(5),
tags: this.lorem.generateWords(3).split(' ')
};
}
product() {
return {
name: this.lorem.generateWords(2).trim(),
description: this.lorem.generateSentences(3).trim()
};
}
}
const factory = new PlaceholderFactory();
console.log(factory.blogPost());
console.log(factory.product());
Keep placeholder text out of production
The one rule that matters: placeholder text must never ship. Gate generation behind an environment check so a stray "Lorem ipsum dolor" can't reach a live page, and strip filler rows before promoting a database.
function getPlaceholder() {
if (process.env.NODE_ENV === 'production') {
throw new Error('Placeholder text must not be used in production');
}
const { loremIpsum } = require('lorem-ipsum');
return loremIpsum({ count: 3, units: 'paragraphs' });
}
Beyond that: document which generator your project uses so new contributors follow the same approach, seed the generator when tests need reproducibility, and generate enough text to stress the layout without drowning the screen.
Bottom line
Automating Lorem Ipsum is a one-import problem in every mainstream language — lorem-ipsum or faker in JavaScript, lorem or Faker in Python, Emmet in your editor, a plugin in Figma, or an API when you want zero dependencies. Match the tool to the job (focused text vs. realistic records vs. inline expansion), copy the correct syntax from the table above, seed it when you need determinism, and fence it off from production. Do that and dummy content stops being a chore and becomes a single function call.