Test data is fake content you use to build, test and demo an app. The best test data looks realistic, never comes from real customers, and stays the same each time you load it. This guide shows you how to put a simple set together, including text and images from Loremly's free API.
Why your app needs test data
An empty app is hard to build. A list screen with no items doesn't tell you much. A profile page with no name or photo hides layout problems. Test data fills those gaps.
You'll use it for three main things:
- Designing screens. You can see how lists, cards and tables look with content in them.
- Testing. Automated tests and manual checks need data to work with, like users, posts or orders.
- Demos. When you show the app to a client or your team, it should look alive, not empty.
Never use real customer data
It can be tempting to copy real data from your live database. It's already there, and it looks realistic. Don't do it.
Real data contains private details like names, emails, addresses and sometimes payment info. Test and demo environments are usually less protected than your live system. Screenshots get shared. Demo builds get sent around. Real data in any of those places is a privacy risk, and it may break privacy laws or your own policies.
Fake data gives you the same benefits with none of that risk.
Types of test data
Most apps need a mix of these:
| Type | Examples | Where to get it |
|---|---|---|
| Text | Bios, comments, post bodies, descriptions | Loremly API or generator |
| Names | First and last names, usernames | A short list you write yourself |
| Emails | Login emails, contact emails | A short list you write yourself |
| Numbers | Prices, ages, counts, dates | Your own code or a small list |
| Images | Avatars, product photos, banners | Loremly photo API |
For names and emails, a small hand-written list is often all you need. Ten or twenty entries will cover most screens. Use the example.com domain for fake emails. It's reserved for examples, so you won't accidentally email a real person.
Keep it repeatable with seeds
Random data is useful, but it can cause trouble. If your test data changes on every run, a bug that showed up yesterday may vanish today. Screenshots won't match. Teammates will see different content.
The fix is a seed. A seed is a fixed value you pass in that makes "random" results come out the same every time. Same seed, same result. Change the seed, and you get different content.
Loremly's API supports a seed parameter for both text and photos. Pick a clear name like demo or user-1, and you'll get the exact same output each time you call it.
Include edge cases
Nice, tidy test data can hide bugs. Real users type all sorts of things. Add some awkward entries on purpose:
- Empty values. A user with no bio. A post with no image. A list with zero items.
- Very long text. A 200-character name. A comment that's several paragraphs long.
- Very short text. A one-letter name. A one-word post.
- Special characters. Accents (José, Zoë), apostrophes (O'Brien), emoji and characters from other languages.
- Symbols that can break code. Text with
<,>,&and quotes. These help you check that your app escapes text safely.
If you need text with an exact length, such as a field's maximum, the character count tool can make it for you.
Load text and images from Loremly's API
Loremly has a free API with no key needed. It also has CORS enabled, which means you can call it straight from a web page in the browser. The API docs list every option.
To get five sentences as JSON:
curl "https://www.loremly.com/api/v1/lorem?unit=sentences&count=5&format=json&seed=demo"
This returns a JSON array of strings, one per sentence. Because of seed=demo, you'll get the same five sentences every time.
To get a photo, use the photo URL directly as an image source:
https://www.loremly.com/api/v1/photo?w=400&h=300&seed=user-1&category=animals
This returns a 400 × 300 photo from the animals category. The seed=user-1 part means it's the same photo each time.
A small JavaScript example
Here's how you might combine a hand-written list of users with text and photos from the API:
const people = [
{ name: "Ana Silva", email: "ana@example.com" },
{ name: "Ben Okafor", email: "ben@example.com" },
{ name: "Chloé Martin", email: "chloe@example.com" },
{ name: "Dev Patel", email: "dev@example.com" },
{ name: "Erin O'Brien", email: "erin@example.com" },
];
async function buildTestUsers() {
const url =
"https://www.loremly.com/api/v1/lorem?unit=sentences&count=5&format=json&seed=demo";
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const bios = await response.json(); // an array of 5 strings
return people.map((person, i) => ({
...person,
bio: bios[i],
avatar: `https://www.loremly.com/api/v1/photo?w=200&h=200&seed=user-${i + 1}&category=animals`,
}));
}
buildTestUsers().then((users) => console.log(users));
Every time this runs, each user gets the same bio and the same avatar. You can save the result to a JSON file for your tests, or load it straight into your app during development. If you just need a quick block of JSON text without code, the JSON dummy text page can make one for you.
Start small
You don't need a huge data set to begin. Start with five to ten records that cover the normal case and a few edge cases. Keep the seeds fixed so everyone sees the same thing. Add more records only when a screen or test really needs them.