How to Generate Bulk Test Data for Database Seeding
Learn how to generate bulk address data for seeding development databases. Cover tools, formats, volume strategies, and common pitfalls.
Why Seed Databases with Test Data?
Development, staging, and test databases need realistic data to function properly. Empty databases do not reveal performance issues, pagination bugs, search indexing problems, or UI layout issues that only appear with real-world data volumes.
Address data is one of the most common types of seeded data because nearly every application that handles users, customers, orders, or locations stores addresses.
How Much Data Do You Need?
Development Environment
Typically 100-1000 records. Enough to:
Staging Environment
Typically 10,000-100,000 records. Enough to:
Performance Testing
100,000+ records. Specifically for:
Generation Approaches
Approach 1: Web-Based Generators
Use a web-based address generator with CSV or JSON export:
Best for: Small to medium datasets (up to 1000 records) when you need data quickly.
Approach 2: Code Libraries
Use a library like Faker to generate data programmatically:
// Node.js example using @faker-js/faker
const { faker } = require('@faker-js/faker');
const fs = require('fs');
const addresses = [];
for (let i = 0; i < 10000; i++) {
addresses.push({
id: i + 1,
street: faker.location.streetAddress(),
city: faker.location.city(),
state: faker.location.state({ abbreviated: true }),
zip: faker.location.zipCode(),
country: 'US',
phone: faker.phone.number(),
created_at: faker.date.past().toISOString(),
});
}
fs.writeFileSync('addresses.json', JSON.stringify(addresses, null, 2));
Best for: Large datasets and automated seeding pipelines.
Approach 3: SQL Seed Scripts
Generate INSERT statements directly:
INSERT INTO addresses (street, city, state, zip, country) VALUES
('742 Oak Avenue', 'Portland', 'OR', '97201', 'US'),
('1588 Elm Drive', 'Austin', 'TX', '73301', 'US'),
('324 Maple Lane', 'Denver', 'CO', '80201', 'US');
-- ... thousands more rows
Best for: When you want a portable seed file that runs in any SQL client.
Approach 4: ORM Seed Scripts
Most ORMs and frameworks have seeding mechanisms:
// Prisma seed example
async function main() {
for (let i = 0; i < 1000; i++) {
await prisma.address.create({
data: {
street: faker.location.streetAddress(),
city: faker.location.city(),
state: faker.location.state({ abbreviated: true }),
zip: faker.location.zipCode(),
},
});
}
}
Best for: Projects already using an ORM with built-in seed support.
Multi-Country Seeding
For international applications, distribute your seed data across target countries:
40% US addresses
20% UK addresses
15% German addresses
10% Canadian addresses
10% Australian addresses
5% Other countries