faker
The faker module generates realistic fake data for testing, seeding databases, and prototyping. It provides deterministic output when seeded for reproducible test cases.
import "faker" for Faker
On This Page
Faker Class
Faker
Generates realistic fake data across many categories
Seeding & Random
Sets the random seed for deterministic output. Use the same seed to generate identical sequences.
- value (Num) - Integer seed value
Faker.seed(12345)
System.print(Faker.name()) // Always produces the same name with this seed
Resets to unseeded mode, using cryptographically random values.
Faker.reset()
System.print(Faker.name()) // Now produces random names
Returns a random element from a list.
var colors = ["red", "green", "blue"]
System.print(Faker.randomElement(colors))
Returns multiple random elements from a list (with possible duplicates).
var picks = Faker.randomElements(["a", "b", "c", "d"], 3)
System.print(picks) // e.g., ["b", "a", "b"]
Returns a random integer between min and max (inclusive).
var age = Faker.randomInt(18, 65)
System.print(age) // e.g., 42
Returns a random float between min and max.
var temp = Faker.randomFloat(20, 30)
System.print(temp) // e.g., 24.7831...
Returns a random float with specified decimal precision.
var price = Faker.randomFloat(10, 100, 2)
System.print(price) // e.g., 47.83
Returns a random boolean. Alias: bool().
var isActive = Faker.boolean()
System.print(isActive) // true or false
Format Helpers
Replaces # characters with random digits.
System.print(Faker.numerify("###-###-####")) // e.g., "415-555-2938"
Replaces ? characters with random lowercase letters.
System.print(Faker.letterify("???-????")) // e.g., "abc-defg"
Replaces both # with digits and ? with letters.
System.print(Faker.bothify("??-###")) // e.g., "ab-123"
Person & Names
Returns a random first name. Gender-specific variants: firstNameMale(), firstNameFemale().
System.print(Faker.firstName()) // e.g., "Emily"
System.print(Faker.firstNameMale()) // e.g., "James"
System.print(Faker.firstNameFemale()) // e.g., "Sarah"
Returns a random last name.
System.print(Faker.lastName()) // e.g., "Johnson"
Returns a full name (first + last). Variants: nameMale(), nameFemale().
System.print(Faker.name()) // e.g., "Emily Johnson"
System.print(Faker.nameMale()) // e.g., "James Smith"
System.print(Faker.nameFemale()) // e.g., "Sarah Williams"
Returns a name prefix (Mr., Mrs., Ms., Miss, Dr.). Alias: namePrefix().
System.print(Faker.prefix()) // e.g., "Dr."
Returns a name suffix (Jr., Sr., MD, PhD, etc.). Alias: nameSuffix().
System.print(Faker.suffix()) // e.g., "Jr."
Returns "Male" or "Female". Alias: sex().
System.print(Faker.gender()) // "Male" or "Female"
Address & Location
Returns a full US-style address.
System.print(Faker.address()) // e.g., "1234 Oak Street, Denver, CO 80201"
Returns a street address (number + street name).
System.print(Faker.streetAddress()) // e.g., "1234 Oak Street"
Returns a street name with suffix.
System.print(Faker.streetName()) // e.g., "Oak Boulevard"
Returns a random building number (1-9999).
System.print(Faker.buildingNumber()) // e.g., "4521"
Returns a US city name.
System.print(Faker.city()) // e.g., "Portland"
Returns a US state name. Aliases: stateFull(), stateName().
System.print(Faker.state()) // e.g., "California"
Returns a US state abbreviation.
System.print(Faker.stateAbbr()) // e.g., "CA"
Returns a country name. Alias: countryName().
System.print(Faker.country()) // e.g., "Germany"
Returns a two-letter country code.
System.print(Faker.countryCode()) // e.g., "DE"
Returns a 5-digit US ZIP code. Alias: postcode().
System.print(Faker.zipCode()) // e.g., "90210"
Returns a random latitude (-90 to 90) with 6 decimal places.
System.print(Faker.latitude()) // e.g., 40.712776
Returns a latitude within a specific range.
System.print(Faker.latitude(30, 50)) // e.g., 42.358429
Returns a random longitude (-180 to 180) with 6 decimal places.
System.print(Faker.longitude()) // e.g., -74.005974
Returns a longitude within a specific range.
System.print(Faker.longitude(-125, -65)) // e.g., -87.629799
Internet & Network
Returns a random email address.
System.print(Faker.email()) // e.g., "john.smith42@gmail.com"
Returns an email using example.com/org/net domains (safe for testing).
System.print(Faker.exampleEmail()) // e.g., "alice_jones@example.org"
Returns a random username in various formats.
System.print(Faker.username()) // e.g., "john.smith", "emily_42"
Returns a 12-character random password.
System.print(Faker.password()) // e.g., "aB3$kLm9@pQr"
Returns a password of specified length.
System.print(Faker.password(20)) // 20-character password
Returns a random URL.
System.print(Faker.url()) // e.g., "https://smith.io"
Returns a domain name.
System.print(Faker.domainName()) // e.g., "johnson.com"
Returns a domain word (without TLD).
System.print(Faker.domainWord()) // e.g., "smith"
Returns a top-level domain. Alias: topLevelDomain().
System.print(Faker.tld()) // e.g., "com", "io", "org"
Returns "http" or "https".
System.print(Faker.protocol()) // "http" or "https"
Returns a random IPv4 address.
System.print(Faker.ipv4()) // e.g., "192.168.45.123"
Returns a random IPv6 address.
System.print(Faker.ipv6()) // e.g., "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
Returns a random MAC address.
System.print(Faker.macAddress()) // e.g., "00:1a:2b:3c:4d:5e"
Returns a random port number (1-65535).
System.print(Faker.port()) // e.g., 8080
Returns a hostname with subdomain.
System.print(Faker.hostname()) // e.g., "server-42.company.com"
Returns a random HTTP method.
System.print(Faker.httpMethod()) // "GET", "POST", "PUT", etc.
Returns a common HTTP status code.
System.print(Faker.httpStatusCode()) // 200, 404, 500, etc.
Returns a realistic browser user agent string.
System.print(Faker.userAgent()) // e.g., "Mozilla/5.0 (Windows NT 10.0..."
Date & Time
Returns a random date within the past 10 years in YYYY-MM-DD format.
System.print(Faker.date()) // e.g., "2021-07-15"
Returns a random datetime within the past 10 years in ISO 8601 format.
System.print(Faker.dateTime()) // e.g., "2022-03-14T09:26:53Z"
Returns a date within the past year. Accepts optional years parameter.
System.print(Faker.pastDate()) // Within past year
System.print(Faker.pastDate(5)) // Within past 5 years
Returns a date within the next year. Accepts optional years parameter.
System.print(Faker.futureDate()) // Within next year
System.print(Faker.futureDate(2)) // Within next 2 years
Returns a random date between two DateTime objects.
import "datetime" for DateTime, Duration
var start = DateTime.now() - Duration.fromDays(30)
var end = DateTime.now()
System.print(Faker.dateBetween(start, end))
Returns a birth date for someone aged 18-80. Accepts optional min/max age.
System.print(Faker.dateOfBirth()) // Age 18-80
System.print(Faker.dateOfBirth(21, 35)) // Age 21-35
Returns a random year (1950-2025).
System.print(Faker.year()) // e.g., 1987
Returns a random month number (1-12).
System.print(Faker.month()) // e.g., 7
Returns a month name.
System.print(Faker.monthName()) // e.g., "July"
Returns a day of the week.
System.print(Faker.dayOfWeek()) // e.g., "Wednesday"
Returns a random day (1-28).
System.print(Faker.dayOfMonth()) // e.g., 15
Returns a random time in HH:MM:SS format.
System.print(Faker.time()) // e.g., "14:32:07"
Returns a random hour (0-23). Related: minute(), second(), amPm().
System.print(Faker.hour()) // e.g., 14
System.print(Faker.minute()) // e.g., 32
System.print(Faker.second()) // e.g., 45
System.print(Faker.amPm()) // "AM" or "PM"
Text & Lorem
Returns a random lorem ipsum word.
System.print(Faker.word()) // e.g., "consectetur"
Returns a list of random words.
System.print(Faker.words(5)) // ["lorem", "ipsum", "dolor", "sit", "amet"]
Returns a sentence (5-12 words). Accepts optional word count.
System.print(Faker.sentence()) // Random length
System.print(Faker.sentence(8)) // Exactly 8 words
Returns multiple sentences joined with spaces.
System.print(Faker.sentences(3)) // Three sentences
Returns a paragraph (3-6 sentences). Accepts optional sentence count.
System.print(Faker.paragraph()) // Random length
System.print(Faker.paragraph(5)) // Exactly 5 sentences
Returns multiple paragraphs separated by double newlines.
System.print(Faker.paragraphs(3)) // Three paragraphs
Returns approximately 200 characters of text. Accepts optional max length.
System.print(Faker.text()) // ~200 characters
System.print(Faker.text(500)) // ~500 characters
Returns a URL-friendly slug (3 words). Accepts optional word count.
System.print(Faker.slug()) // e.g., "lorem-ipsum-dolor"
System.print(Faker.slug(5)) // e.g., "lorem-ipsum-dolor-sit-amet"
Colors
Returns a color name.
System.print(Faker.colorName()) // e.g., "Crimson"
Returns a hex color code.
System.print(Faker.hexColor()) // e.g., "#a3c2f0"
Returns an RGB color string. Alias: rgb().
System.print(Faker.rgbColor()) // e.g., "rgb(163, 194, 240)"
Returns an RGBA color string with random alpha.
System.print(Faker.rgbaCssColor()) // e.g., "rgba(163, 194, 240, 0.75)"
Company & Job
Returns a company name. Alias: companyName().
System.print(Faker.company()) // e.g., "Smith Industries"
Returns a company suffix.
System.print(Faker.companySuffix()) // e.g., "LLC", "Inc.", "Corp."
Returns a job title. Alias: jobTitle().
System.print(Faker.job()) // e.g., "Software Engineer"
Returns a job level descriptor.
System.print(Faker.jobDescriptor()) // e.g., "Senior", "Lead", "Principal"
Commerce & Products
Returns a product name. Alias: productName().
System.print(Faker.product()) // e.g., "Elegant Steel Chair"
Returns a product category.
System.print(Faker.productCategory()) // e.g., "Electronics"
Returns a price (1-1000) with 2 decimal places. Accepts optional min/max.
System.print(Faker.price()) // e.g., 49.99
System.print(Faker.price(10, 50)) // e.g., 24.95
Returns a currency code.
System.print(Faker.currency()) // e.g., "USD", "EUR", "GBP"
Returns a currency name.
System.print(Faker.currencyName()) // e.g., "US Dollar"
Returns a currency symbol.
System.print(Faker.currencySymbol()) // e.g., "$", "€", "£"
Returns a credit card type.
System.print(Faker.creditCardType()) // e.g., "Visa", "Mastercard"
Returns a formatted credit card number.
System.print(Faker.creditCardNumber()) // e.g., "4123-4567-8901-234"
Returns a 3-digit CVV code.
System.print(Faker.creditCardCVV()) // e.g., "123"
Returns an expiry date in MM/YY format.
System.print(Faker.creditCardExpiryDate()) // e.g., "09/27"
Returns a US-format phone number. Alias: phone().
System.print(Faker.phoneNumber()) // e.g., "(415) 555-1234"
Banking & Finance
Returns an IBAN (International Bank Account Number).
System.print(Faker.iban()) // e.g., "DE89370400440532013000"
Returns a 10-digit account number. Accepts optional length.
System.print(Faker.accountNumber()) // 10 digits
System.print(Faker.accountNumber(12)) // 12 digits
Returns a 9-digit routing number.
System.print(Faker.routingNumber()) // e.g., "123456789"
Files & Hashes
Returns a file name with extension.
System.print(Faker.fileName()) // e.g., "document.pdf"
Returns a file extension.
System.print(Faker.fileExtension()) // e.g., "pdf", "jpg", "txt"
Returns a MIME type.
System.print(Faker.mimeType()) // e.g., "application/json"
Returns a semantic version string.
System.print(Faker.semver()) // e.g., "2.14.3"
Returns a UUID v4.
System.print(Faker.uuid()) // e.g., "550e8400-e29b-41d4-a716-446655440000"
Returns an MD5 hash string.
System.print(Faker.md5()) // 32-character hex string
Returns a SHA-1 hash string.
System.print(Faker.sha1()) // 40-character hex string
Returns a SHA-256 hash string.
System.print(Faker.sha256()) // 64-character hex string
Utilities
Returns a random digit (0-9). Alias: randomDigit().
System.print(Faker.digit()) // 0-9
Returns a list of random digits.
System.print(Faker.digits(4)) // e.g., [1, 4, 7, 2]
Returns a random lowercase letter.
System.print(Faker.letter()) // e.g., "k"
Returns a string of random lowercase letters.
System.print(Faker.letters(6)) // e.g., "xkjmvq"
Returns a shuffled copy of the list.
var nums = [1, 2, 3, 4, 5]
System.print(Faker.shuffle(nums)) // e.g., [3, 1, 5, 2, 4]
Returns a complete user profile with username, name, email, address, phone, job, company, and birthdate.
var user = Faker.profile()
System.print(user["name"])
System.print(user["email"])
System.print(user["company"])
Returns a basic profile with username, name, email, and address.
var user = Faker.simpleProfile()
System.print(user["name"])
System.print(user["email"])
Returns the current locale (always "en_US").
System.print(Faker.locale()) // "en_US"
Examples
Seeding for Reproducible Tests
import "faker" for Faker
Faker.seed(42)
var user1 = Faker.name()
var user2 = Faker.name()
Faker.seed(42)
System.print(Faker.name() == user1) // true
System.print(Faker.name() == user2) // true
Generating Test Users
import "faker" for Faker
import "json" for Json
var users = []
for (i in 0...5) {
users.add({
"id": Faker.uuid(),
"name": Faker.name(),
"email": Faker.email(),
"age": Faker.randomInt(18, 65),
"active": Faker.boolean()
})
}
System.print(Json.stringify(users, 2))
Creating Product Catalog
import "faker" for Faker
for (i in 0...3) {
System.print("Product: %(Faker.product())")
System.print("Category: %(Faker.productCategory())")
System.print("Price: %(Faker.currencySymbol())%(Faker.price())")
System.print("---")
}
Generating Addresses
import "faker" for Faker
for (i in 0...3) {
System.print(Faker.address())
System.print(" Lat: %(Faker.latitude())")
System.print(" Lng: %(Faker.longitude())")
System.print("")
}
When unseeded, Faker uses cryptographically secure random numbers from the crypto module. When seeded, it uses a deterministic linear congruential generator for reproducibility.
Use seeding in tests to ensure consistent, reproducible test data. Call Faker.reset() to return to random mode for production use.