Random Phone Number Generator API: Generate Fake Phone Numbers

Testing forms or systems that collect phone numbers? The Random Phone Number Generator API creates properly formatted fake phone numbers for any country, including area codes, international formats, and mobile vs. landline distinctions.

Why Generate Fake Phone Numbers?

Phone number validation is notoriously tricky - different countries have different formats, lengths, and rules. Testing with random digits often fails validation, while using real numbers raises privacy concerns.

The API generates numbers that follow each country's numbering plan, using valid area codes and proper formatting, while ensuring the numbers are not assigned to real subscribers.

Supported Phone Formats

The API generates phone numbers with country-specific formatting:

United States / Canada

NANP format: (555) 123-4567 or +1-555-123-4567

United Kingdom

+44 20 1234 5678 (landline) or +44 7911 123456 (mobile)

International E.164

Standard international format: +[country code][number]

Custom Formatting

Raw digits, dashes, dots, spaces, or parentheses

Safety Note: Generated numbers use reserved ranges (like 555 in the US) when available, ensuring they cannot reach real subscribers.

Using the Random Phone API

TinyFn provides a flexible endpoint to generate random phone numbers:

API Request
GET https://api.tinyfn.io/v1/generate/phone?country=US&format=national
Headers: X-API-Key: your-api-key
Response
{
  "phone": {
    "number": "(555) 847-2938",
    "raw": "5558472938",
    "e164": "+15558472938",
    "country_code": "1",
    "area_code": "555",
    "type": "landline"
  },
  "country": "US",
  "format": "national"
}

Parameters

Parameter Type Description
country string ISO country code: US, UK, CA, AU, DE, FR (default: US)
format string Format style: national, international, e164, raw (default: national)
type string Phone type: mobile, landline, any (default: any)
count integer Generate multiple numbers (1-100, default: 1)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/generate/phone?country=US&type=mobile',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const { phone } = await response.json();
console.log(`Phone: ${phone.number}`);
console.log(`E.164: ${phone.e164}`);

Python

import requests

response = requests.get(
    'https://api.tinyfn.io/v1/generate/phone',
    headers={'X-API-Key': 'your-api-key'},
    params={'country': 'UK', 'format': 'international', 'count': 10}
)
data = response.json()
for phone in data['phones']:
    print(f"{phone['number']} ({phone['type']})")

cURL

curl "https://api.tinyfn.io/v1/generate/phone?country=CA&format=e164" \
  -H "X-API-Key: your-api-key"

Common Use Cases

  • Form Validation Testing: Test phone input fields with various formats
  • SMS Integration Testing: Test workflows without sending real messages
  • Database Seeding: Populate test databases with realistic phone data
  • Contact Forms: Test contact management systems
  • International Support: Test phone formatting across countries

Best Practices

  1. Test multiple countries: Validate international phone handling
  2. Test all formats: Ensure your system handles various formatting styles
  3. Use E.164 for storage: Store numbers in standard E.164 format
  4. Test mobile vs landline: Some features may differ by phone type
  5. Never send SMS to generated numbers: They are for validation testing only

Try the Random Phone API

Get your free API key and start generating test phone numbers.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key