Skip to content


The simplest way to use Datafaker to generate fake data is by instantiating the Faker using the default constructor.

Default usage

import net.datafaker.Faker;

Faker faker = new Faker();

String name =; // Miss Samanta Schmidt
import net.datafaker.Faker

val faker = Faker()

val name = // Miss Samanta Schmidt

This will instantiate a Faker using the English locale.

Different locale

To use Datafaker with a different locale, you can supply on in the constructor as such:

Faker faker = new Faker(new Locale("nl"));

String name =; // Chelan Klijnsma
val faker = Faker(Locale("nl"))

val name = // Chelan Klijnsma

Multiple locales

In case you want to mix locales, the easiest way to do so is to create a Faker per locale, and mix between those fakers. For an example, see below, which produce something like the following:

8708 شارع قطر, مدينة خولة
جناح 385 127 شارع العشرين, معبر عبدالله
Schlangenlaan 461a, Oost Jessamyingen, WV 8234 ZX
1 hoog Gritlaan 52, Margiesmeer, OK 1083 VE
Faker faker1 = new Faker(new Locale("nl"));
Faker faker2 = new Faker(new Locale("ar"));

List<Faker> fakers = Arrays.asList(faker1, faker2);

for (int i = 0; i < 10; i++) {
    Faker randomFaker = new Faker().options().nextElement(fakers);
val faker1 = Faker(Locale("nl"))
val faker2 = Faker(Locale("ar"))

val fakers = listOf(faker1, faker2)

repeat(10) {
    val randomFaker = Faker().options().nextElement(fakers)

Repeatable random results

To generate a more predictable random result, it's possible to provide a seed value to the Faker.

When providing a seed, the instantiation of Fake objects will always happen in a predictable way, which can be handy for generating results multiple times.

Faker faker = new Faker(new Random(0));
val faker = Faker(Random(0))

Random Java enum values

To get a random value from a Java enum you can employ the Options.option() method.

The following example assumes you want to retrieve a random value from the Day enum.

enum Day {

private final Options opt = faker.options();
Back to top