| name | lorem-ipsum-generator |
| description | Generate placeholder text (lorem ipsum) in various formats. Create paragraphs, sentences, words, or custom templates for mockups and testing. |
Lorem Ipsum Generator
Generate placeholder text for mockups, wireframes, and testing purposes.
Features
- Classic Lorem: Traditional lorem ipsum text
- Multiple Formats: Paragraphs, sentences, words, lists
- Custom Length: Specify exact word/sentence/paragraph counts
- HTML Output: Generate with HTML tags
- Alternative Sources: Hipster, bacon, corporate ipsum variations
- Templates: Fill templates with placeholder text
Quick Start
from lorem_gen import LoremGenerator
gen = LoremGenerator()
text = gen.paragraphs(3)
print(text)
sentences = gen.sentences(5)
print(sentences)
words = gen.words(50)
print(words)
CLI Usage
python lorem_gen.py --paragraphs 3
python lorem_gen.py --sentences 5
python lorem_gen.py --words 100
python lorem_gen.py --paragraphs 3 --html
python lorem_gen.py --list 5
python lorem_gen.py --paragraphs 3 --words-per 50
python lorem_gen.py --paragraphs 3 --style hipster
python lorem_gen.py --paragraphs 5 --output placeholder.txt
API Reference
LoremGenerator Class
class LoremGenerator:
def __init__(self, style: str = "classic")
def paragraphs(self, count: int = 3, words_per: int = None) -> str
def sentences(self, count: int = 5) -> str
def words(self, count: int = 50) -> str
def list_items(self, count: int = 5, ordered: bool = False) -> str
def heading(self, level: int = 1) -> str
def title(self, words: int = 4) -> str
def html_paragraphs(self, count: int = 3) ->
() ->
() ->
() ->
() ->
Output Formats
Paragraphs
text = gen.paragraphs(2)
Sentences
text = gen.sentences(3)
Words
text = gen.words(10)
Lists
text = gen.list_items(3)
text = gen.list_items(3, ordered=True)
HTML Output
HTML Paragraphs
html = gen.html_paragraphs(2)
HTML List
html = gen.html_list(3, ordered=False)
HTML Article
html = gen.html_article(sections=2)
Text Styles
Classic Lorem Ipsum
Traditional Latin placeholder text:
gen = LoremGenerator(style="classic")
Hipster Ipsum
Trendy, modern vocabulary:
gen = LoremGenerator(style="hipster")
Corporate Ipsum
Business jargon:
gen = LoremGenerator(style="corporate")
Tech Ipsum
Technology-focused text:
gen = LoremGenerator(style="tech")
Templates
Fill templates with placeholder text:
template = """
# {{title}}
{{paragraph}}
## Features
{{list:5}}
## Details
{{paragraph}}
{{paragraph}}
"""
result = gen.fill_template(template)
Template Placeholders
| Placeholder | Output |
|---|
{{title}} | 3-5 word title |
{{heading}} | Section heading |
{{paragraph}} | Single paragraph |
{{sentence}} | Single sentence |
{{words:N}} | N words |
{{list:N}} | N list items |
{{name}} | Random name |
{{email}} | Random email |
{{date}} | Random date |
Specific Word Counts
Control exact word count per paragraph:
text = gen.paragraphs(3, words_per=50)
text = gen.words(200)
Example Workflows
Mockup Text Generation
gen = LoremGenerator()
title = gen.title(words=6)
intro = gen.paragraphs(1, words_per=100)
body = gen.paragraphs(3, words_per=150)
conclusion = gen.paragraphs(1, words_per=75)
print(f"# {title}\n\n{intro}\n\n{body}\n\n{conclusion}")
HTML Page Content
gen = LoremGenerator()
html = f"""
<!DOCTYPE html>
<html>
<body>
<header>
<h1>{gen.title()}</h1>
</header>
<main>
{gen.html_paragraphs(3)}
<h2>Features</h2>
{gen.html_list(5)}
{gen.html_paragraphs(2)}
</main>
</body>
</html>
"""
Test Data Generation
gen = LoremGenerator()
articles = []
for i in range(10):
articles.append({
"title": gen.title(),
"excerpt": gen.sentences(2),
"body": gen.paragraphs(5),
"tags": gen.words(3).split()
})
Dependencies
- faker>=22.0.0 (optional, for enhanced fake data)