Testing•9 min read
ID Generators Guide: UUID, Test Numbers, and More
Generate test IDs for development. Create UUIDs, test credit cards, Australian business numbers, and more.
By Andy Pham
ID Generators Guide: UUID, Test Numbers, and More
Generate valid test identifiers for development and testing. These tools create properly formatted IDs that pass validation.
UUID Generation
UUID Versions
| Version | Description | Use Case |
|---|---|---|
| v1 | Timestamp + MAC | Ordered IDs |
| v4 | Random | Most common |
| v5 | Namespace + Name | Deterministic |
| v7 | Timestamp + Random | Sortable |
JavaScript UUID v4
function generateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
// Using crypto API
function secureUUID() {
return crypto.randomUUID();
}
Test Credit Card Numbers
Valid Test Numbers
| Card | Number | Use |
|---|---|---|
| Visa | 4111111111111111 | Testing |
| Mastercard | 5500000000000004 | Testing |
| Amex | 340000000000009 | Testing |
| Discover | 6011000000000004 | Testing |
Luhn Algorithm Check
function isValidLuhn(number) {
const digits = number.replace(/D/g, '');
let sum = 0;
let isEven = false;
for (let i = digits.length - 1; i >= 0; i--) {
let digit = parseInt(digits[i], 10);
if (isEven) {
digit *= 2;
if (digit > 9) digit -= 9;
}
sum += digit;
isEven = !isEven;
}
return sum % 10 === 0;
}
Australian Business Numbers
ACN (Australian Company Number)
- 9 digits
- Weighted checksum algorithm
function generateACN() {
const weights = [8, 7, 6, 5, 4, 3, 2, 1];
let digits = [];
for (let i = 0; i < 8; i++) {
digits.push(Math.floor(Math.random() * 10));
}
let sum = 0;
for (let i = 0; i < 8; i++) {
sum += digits[i] * weights[i];
}
const checkDigit = (10 - (sum % 10)) % 10;
digits.push(checkDigit);
return digits.join('');
}
TFN (Tax File Number)
- 8 or 9 digits
- Weighted checksum
Medicare Number
- 10 or 11 digits
- Specific format with check digit
Important Notes
These generators create test data only:
- Do not use for fraud
- For development/testing only
- Real IDs have additional validation
- Test numbers may be flagged in production
Try Our ID Generators
Conclusion
Test ID generators help create realistic test data while following proper validation rules.