Skip to main content

Generating fake data

Kreya can generate fake but realistic data such as names, emails, numbers, UUIDs and dates. This is useful for filling request bodies, generating unique identifiers, or creating data-driven tests. Fake data generation is powered by Bogus and is available both in templating and in scripts.

In templating

Anywhere templating is supported, the faker object is available. For example:

I am {{ faker.name.full_name }} and my email is {{ faker.internet.email }}

renders something like:

I am Jazlyn Gorczany and my email is [email protected]

Available categories

The faker object exposes the following categories. Methods are written in snake_case in templating (e.g. faker.name.full_name).

CategoryExamples
faker.addresscity, country, zip_code, full_address
faker.commerceproduct, price, department
faker.companycompany_name, catch_phrase
faker.databasecolumn, engine, type
faker.datepast, future, recent, soon, between (see Dates)
faker.financeaccount, amount, currency_code, credit_card_number
faker.hackerphrase, verb, noun
faker.imagepicture_url, loremflickr_url
faker.internetemail, user_name, url, ip, mac
faker.loremword, sentence, paragraph
faker.musicgenre
faker.namefirst_name, last_name, full_name, job_title
faker.phonephone_number
faker.randomguid, uuid, number, int, bool, word
faker.systemfile_name, mime_type, semver
faker.vehiclemanufacturer, model, vin

A GUID is a common case. By default a GUID renders with dashes; use Scriban's object.format to change the representation, for example to a 32-digit form without dashes:

{{ faker.random.guid }}
{{ faker.random.guid | object.format 'N' }}

Dates

faker.date generates random dates relative to now:

MethodResult
faker.date.pastA date in the past
faker.date.recentA date within the last few days
faker.date.soonA date within the next few days
faker.date.futureA date in the future
faker.date.betweenA date between two explicit dates

A generated date is a date/time value. To output it in a specific format, pipe it through Scriban's built-in date.to_string function, which uses strftime-style placeholders:

Date only:     {{ faker.date.past | date.to_string '%Y-%m-%d' }}
ISO 8601 UTC: {{ faker.date.past | date.to_string '%Y-%m-%dT%H:%M:%SZ' }}

To generate a date in a specific time range — for example "sometime in the next 30 days" — use faker.date.soon with the number of days, or faker.date.between for an explicit range built with the Scriban date helpers:

# Within the next 30 days:
{{ faker.date.soon 30 | date.to_string '%Y-%m-%d' }}

# Between now and 30 days from now (explicit range):
{{ faker.date.between date.now (date.add_days date.now 30) | date.to_string '%Y-%m-%dT%H:%M:%SZ' }}

faker.date.future similarly accepts the number of years to go forward, and faker.date.past the number of years to go back.

In scripts Pro / Enterprise

In scripts the same data is available through kreya.faker. Here, methods use camelCase and are called as functions:

const name = kreya.faker.name.fullName();
const email = kreya.faker.internet.email();
const id = kreya.faker.random.uuid();
const amount = kreya.faker.finance.amount();

kreya.faker.date.* returns a JavaScript Date, so you can format it with the standard JavaScript APIs or generate it within a range:

// A date within the next 30 days, formatted as ISO 8601
const soon = kreya.faker.date.soon(30);
kreya.variables.set('due_date', soon.toISOString());

// A date in an explicit range
const start = new Date();
const end = new Date();
end.setDate(end.getDate() + 30);
const inRange = kreya.faker.date.between(start, end);

// Custom format (e.g. yyyy-MM-dd) using Intl
const formatted = new Intl.DateTimeFormat('en-CA').format(inRange); // 2026-05-19

For more advanced date formatting in scripts you can also import a date library such as date-fns, see importing external modules.

The full list of available members is documented in the faker script API reference.