What is a Random JSON Generator?
A random JSON generator creates realistic mock data for development and testing. Instead of manually writing test fixtures, you define the structure (field names and types) and the tool generates hundreds of realistic records instantly — names, emails, UUIDs, dates, coordinates and more.
Mock data is essential for frontend development (building UI before the API is ready), unit and integration testing (reproducible test fixtures), load testing (filling a database with realistic data), API prototyping (demoing endpoints without production data), and presentations (realistic-looking demos without exposing real user data).
Available Field Types
| Type | Example output | Use case |
|---|---|---|
| name | Arjun Patel | Full name for user records |
| arjun.patel42@example.com | User email, login tests | |
| uuid | a1b2c3d4-e5f6-4… | Primary keys, correlation IDs |
| int | 4271 | Age, count, score, quantity |
| float | 87.43 | Price, rating, percentage |
| boolean | true / false | Active flag, feature toggle |
| date | 2024-11-03 | Birth date, created_at (date only) |
| url | https://example.com/widget/… | Avatar URL, profile link |
| phone | +1-512-834-7291 | Contact number |
| word | lambda | Tag, category, keyword |
| sentence | cache matrix open… | Description, bio, note |
| country | India | Country name |
| city | Surat | City name |
Seeding Random Data in Go Tests
go
// go get github.com/brianvoe/gofakeit/v6
import "github.com/brianvoe/gofakeit/v6"
type User struct {
ID string
Name string
Email string
Age int
}
func randomUser() User {
return User{
ID: gofakeit.UUID(),
Name: gofakeit.Name(),
Email: gofakeit.Email(),
Age: gofakeit.Number(18, 80),
}
}
// Generate a slice of random users
func randomUsers(n int) []User {
users := make([]User, n)
for i := range users {
users[i] = randomUser()
}
return users
}Mock Data in JavaScript Tests
javascript
// npm install @faker-js/faker
import { faker } from '@faker-js/faker';
function randomUser() {
return {
id: faker.string.uuid(),
name: faker.person.fullName(),
email: faker.internet.email(),
age: faker.number.int({ min: 18, max: 80 }),
active: faker.datatype.boolean(),
city: faker.location.city(),
createdAt: faker.date.past().toISOString(),
};
}
// Generate 10 random users
const users = Array.from({ length: 10 }, randomUser);
console.log(JSON.stringify(users, null, 2));