Skip to content

Generating placeholder text for test layouts

4 min read API guides

generate placeholder text

To generate placeholder text, start with the shape the final copy will have. A layout needs text with a realistic shape. A single short line does not show how a paragraph wraps, how a heading breaks or how a card behaves with three lines instead of one. Placeholder text fills that gap during development.

The Text placeholder endpoint returns filler text with a chosen number of sentences and words.

curl "https://api2.globus.studio/v2/ph_text?sentences=3&words=12&format=json"

Parameters

To generate placeholder text with a set length, use sentences for the number of sentences. words sets the words per sentence. The old names sentence and word still work. Values above 250 fall back to 100 to keep the response bounded.

Why the output changes

A generate placeholder text call returns a new combination of words. That is useful when you want to see a layout with different word lengths. If you need the same generate placeholder text output for a screenshot test, save the response and use the saved file.

Text format

To generate placeholder text in HTML, omit the format parameter. With format=json it returns the text with the actual sentence and word counts. The JSON shape is easier to assert in a test.

Keep it out of production

Generate placeholder text for fixtures and prototypes only. Placeholder copy belongs there. A generate placeholder text result on a live page looks unfinished and gives search engines nothing useful. Replace it before launch, even on a page that is not in the navigation.

A small test helper

def filler(sentences=2, words=8):
    response = requests.get(
        "https://api2.globus.studio/v2/ph_text",
        params={"sentences": sentences, "words": words, "format": "json"},
        timeout=10,
    )
    return response.json()["text"]

Limits

The endpoint is fast and rate limited. It does not translate or follow a topic. Read the endpoint documentation for parameters and examples.

Testing overflow

Generate a short paragraph and a long one. Check the card at both lengths. A title that wraps to three lines can push a button out of the card. Placeholder text with varied word lengths exposes that faster than a repeated sentence.

Localization

German words are longer than English words. A layout tested only with English can break when a translation arrives. If the site will support more languages, test with a longer locale or with a text string that has long words.

Generate placeholder text for a snapshot test

Random text changes on every call, which breaks a snapshot. Save one response to a fixture and use the fixture in the test. Keep the endpoint for manual reviews and new fixtures. Read the documentation for the format parameter.

A minimal test page

Build one page with three cards, a long heading and a paragraph. Fill each slot with a different length. Check the layout at 320, 768 and 1440 pixels. The page is small, but it catches the overflow and wrapping problems that a single repeated sentence hides.

Word counts that expose a bug

Three lengths catch most layout defects: one short sentence, one paragraph of about 60 words and one block of 200 words. The short sentence shows whether a card has a minimum height. The 60-word paragraph shows the normal case. The 200-word block shows what happens when the copy is longer than the designer expected.

Repeat the test with a long word, such as a URL or a German compound noun. A layout that only sees English prose can break when a translation arrives. The endpoint does not translate, so generate a long string yourself and paste it into the fixture.

Keep the page in the repository as a fixture. Run it after a CSS change. It is faster than clicking through the real catalog and it does not depend on production content.

Related reading

To generate placeholder text that matches a real page, use placeholder images for the media slot and QR codes for a link block. The goal is a page that looks like the final one at every breakpoint, with content that is obviously temporary. Replace the filler before the page is indexed.

Further reading: W3C Web Accessibility Initiative.

Custom work

Need an API that does not exist yet?

Describe the task and the response format. We will estimate the endpoint, the integration and the maintenance.

Start a conversation