This project was created by a developer from Ukraine. Russia has invaded Ukraine and already killed tens of thousands of civilians, with many more raped or tortured. The death toll keeps climbing. It's a genocide. We need your help. Let's fight back against the Russian regime. Russia has invaded Ukraine and already killed tens of thousands of civilians, with many more raped or tortured. It's a genocide. We need your help. Help Ukraine Now
kotlin-faker

kotlin-faker: the ultimate fake data generation library for development and testing

Kotlin-faker is a comprehensive data-generation library for the JVM. It is most suitable for development, testing, and data anonymization purposes, and can be used with Kotlin, Java, Android, Scala, and other JVM-based projects. Kotlin-faker provides realistic-looking, fake data generation capabilities in various domains like names, addresses, internet, banking, books, games, and many more.

In fact, kotlin-faker is so good at generating fake data, it almost fooled us into thinking it was real! 🤯 From names that sound like they belong to secret agents🕴️, to addresses where superheroes 🦸‍♂️ and villains 🦹 might live.
Use kotlin-faker during development and testing to ensure your application data looks as if it was real, just like this really fake logo, but not quite so.

Kotlin-faker is a kotlin port of a popular ruby faker gem.

⚠️ P.S. All names, addresses, bank accounts, and other data generated by this library - even those based on real strings - are entirely fictional. All produced data is fake and generated... poorly. The data is completely made up, but the problems that it tries to solve are real. We take no responsibility for any existential crises caused by the eerily convincing fake data. Use with caution! ⚠️


Some of the bits that kotlin-faker gives you are…

…a plethora of real-looking data in various domains:

val faker = Faker()
Names
faker.name.nameWithMiddle() // => Dr. John Abrams Smith
Addresses
faker.address.streetAddress() // => 474 Kilback Manor
Internet
faker.internet.safeEmail() // => chance.marvin@yahoo.test
Banking
val faker = CommerceFaker()
faker.bank.swiftBic() // => AACCGB21
Books
val faker = BooksFaker()
faker.book.genre() // => Fantasy
Movies and TV
val faker = MoviesFaker()
faker.starWars.characters() // => Darth Vader
val faker = TvShowsFaker()
faker.friends.characters() // => Phoebe Buffay
…and many others
// a total of 213 different data providers

…in 60 locales:

val config = fakerConfig { locale = "nb-NO" }
val faker = Faker(config)
nb_NO -> city
faker.address.city() // => Høyberg
nb_NO -> person‘s name
faker.name.nameWithMiddle() // => Sofie Ødegård Løken

…“unique data generation”:

val faker = Faker()
Generate unique values within a domain
faker.unique.configuration {
    // enable generation of unique values for address data provider
    enable(faker::address)
}
val countries = List(100) { faker.address.country() }
assertEquals(countries.distinct().size, 100)
Generate unique values within a function
val countries = List(100) { faker.address.unique.country() }
val cities = List(1000) { faker.address.city() }
assertEquals(countries.distinct().size, 100)
assertTrue(cities.distinct().size < 1000)

…cli native app for looking up data generators:

faker-bot lookup name --verbose
#Faker()
#├── address
#│   ├── cityName() // => Port Olinstad
#│   ├── countryByName() // => NR
#│   └── streetName() // => Lance Roads
#├── animal
#│   └── name() // => gnat
#├── app
#│   └── name() // => Bamity
#├── artist
#│   └── names() // => Cezanne
#├── bank
#│   └── name() // => ABN AMRO HOARE GOVETT SECURITIES
#├── beer
#│   └── name() // => Oaked Arrogant Bastard Ale
# rest of output that matches query

…and more:

val faker = Faker()
Random instance of any class…
class Foo(val a: String)
class Bar(val foo: Foo)

val foo: Foo = faker.randomClass.randomClassInstance()
val bar: Bar = faker.randomClass.randomClassInstance()
…with pre-configured type generation
class Baz(val id: Int, val uuid: UUID, val username: String)

val baz: Baz = faker.randomClass.randomClassInstance {
    // ヽ(^o^)丿 ᕕ(ᐛ)ᕗ Prepend string type parameter values with parameter name!
    typeGenerator<String> { parameterInfo -> "${parameterInfo.name}_${randomString()}" }
    typeGenerator<UUID> { UUID.fromString("00000000-0000-0000-0000-000000000000") }
    typeGenerator<Int> { faker.random.nextInt(min = 0, max = 9) }
}
assertEquals(baz.username, "username_X3a8s813dcb")
assertEquals(baz.uuid, UUID.fromString("00000000-0000-0000-0000-000000000000"))
assertTrue(baz.id in 0..9)
String templates
faker.string.numerify("foo###bar") // foo123bar
faker.string.letterify("foo???bar", true) // fooXYZbar
faker.string.bothify("foo?##bar", false) // foox42bar
faker.string.regexify("""\d{2}\w""") // 42a
Random numbers, strings, enums, UUIDs, and more…
faker.random.nextInt(intRange = 0..1000)
faker.random.nextLong(bound = 999L)
faker.random.randomString(length = 99)
faker.random.nextEnum<TestEnum>()
faker.random.nextEnum(TestEnum::class.java) {
    it != TestEnum.SOME // Exclude 'SOME' enum
}
faker.random.nextUUID()

See the pages under the User Guide section, jump straight to the Getting Started page, or explore the Data Provider API or the Full Core API documentation to learn more.