Need to generate test email addresses for your application? This guide covers everything about random email generation via API, including format options, domain customization, and implementation examples in multiple programming languages.
Why Generate Random Emails?
Random email generation is essential for testing registration flows, populating databases with realistic data, and developing email-related features without using real addresses. Generated emails look authentic but don't exist.
Example output: john.smith42@example.com, emily_wilson@testmail.dev
Email Formats
Different email patterns you can generate:
Name-Based
firstname.lastname@domain.com or first_last@domain.com
Random String
Random alphanumeric strings for anonymous testing
Custom Domains
Use specific domains like @example.com or your own domain
Using the Random Email API
TinyFn provides a flexible endpoint to generate random emails:
GET https://api.tinyfn.io/v1/generate/email?count=5
Headers: X-API-Key: your-api-key
{
"emails": [
"john.smith@example.com",
"emily.wilson42@testmail.dev",
"mike_johnson@example.org",
"sarah.chen@demo.test",
"alex.kumar@example.net"
],
"count": 5
}
Parameters
| Parameter | Type | Description |
|---|---|---|
count |
integer | Number of emails to generate (default: 1, max: 100) |
domain |
string | Specific domain to use (optional) |
format |
string | Format: name, random, both (default: name) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/generate/email?count=5',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const { emails } = await response.json();
emails.forEach(email => console.log(email));
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/generate/email',
params={'count': 5},
headers={'X-API-Key': 'your-api-key'}
)
emails = response.json()['emails']
for email in emails:
print(email)
cURL
curl "https://api.tinyfn.io/v1/generate/email?count=5" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Testing: Test registration and login flows
- Database Seeding: Populate test databases with user data
- Load Testing: Generate unique emails for stress testing
- Demo Data: Create realistic demo accounts
- Privacy: Use generated emails instead of real ones in examples
Best Practices
- Use safe domains: Stick to example.com, .test TLDs for testing
- Mark as test: Clearly label generated emails as fake in your database
- Don't send emails: Never send actual emails to generated addresses
- Unique generation: Ensure generated emails are unique within your dataset
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-generate": {
"url": "https://api.tinyfn.io/mcp/generate/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all generator tools available via MCP in our Generator MCP Tools for AI Agents guide.
Try the Random Email Generator API
Get your free API key and start generating test emails in seconds.
Get Free API Key