Lorem Ipsum Generator — Developer Code Samples
Lorem Ipsum is standard placeholder text used in design and development. Generate it programmatically using Python's lorem library, a JavaScript snippet, or a simple shell script — useful for seeding databases and filling UI mockups.
Try the interactive version online:
Open Lorem Ipsum Generator Tool →
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| paragraphs | int | No | Number of paragraphs to generate (default: 3) |
| sentences | int | No | Sentences per paragraph (default: 5) |
| start_classic | bool | No | Start with classic Lorem Ipsum opening (default: True) |
Returns: Lorem Ipsum placeholder text as a string with newline-separated paragraphs
Code Examples
import random
import textwrap
# Classic Lorem Ipsum words
LOREM_WORDS = [
"lorem", "ipsum", "dolor", "sit", "amet", "consectetur",
"adipiscing", "elit", "sed", "do", "eiusmod", "tempor",
"incididunt", "ut", "labore", "et", "dolore", "magna", "aliqua",
"enim", "ad", "minim", "veniam", "quis", "nostrud", "exercitation",
"ullamco", "laboris", "nisi", "aliquip", "ex", "ea", "commodo",
"consequat", "duis", "aute", "irure", "in", "reprehenderit",
"voluptate", "velit", "esse", "cillum", "fugiat", "nulla",
"pariatur", "excepteur", "sint", "occaecat", "cupidatat", "non",
"proident", "sunt", "culpa", "qui", "officia", "deserunt",
"mollit", "anim", "id", "est", "laborum"
]
CLASSIC_PARAGRAPH = (
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "
"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo "
"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse "
"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non "
"proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
)
def generate_sentence(min_words=6, max_words=14):
count = random.randint(min_words, max_words)
words = random.choices(LOREM_WORDS, k=count)
return " ".join(words).capitalize() + "."
def generate_paragraph(sentences=5):
return " ".join(generate_sentence() for _ in range(sentences))
def generate_lorem(paragraphs=3, start_classic=True):
result = []
if start_classic:
result.append(CLASSIC_PARAGRAPH)
for _ in range(paragraphs - 1):
result.append(generate_paragraph())
else:
for _ in range(paragraphs):
result.append(generate_paragraph())
return "\n\n".join(result)
# Generate 3 paragraphs
print(generate_lorem(3))
# Generate word count only
def generate_words(count):
return " ".join(random.choices(LOREM_WORDS, k=count)).capitalize() + "."
print(generate_words(50))