Cheat Sheet

View Source

A quick reference for the most commonly used random data generator functions.

App

author(opts \\ [])

iex> NeoFaker.App.author()
"José Valim"

description(opts \\ [])

iex> NeoFaker.App.description()
"Elixir library for generating fake data in tests and development."

iex> NeoFaker.App.description(locale: :id_id)
"Pustaka Elixir untuk menghasilkan data palsu dalam pengujian dan pengembangan."

license()

iex> NeoFaker.App.license()
"MIT License"

name(opts \\ [])

iex> NeoFaker.App.name()
"Neo Faker"

iex> NeoFaker.App.name(style: :camel_case)
"neoFaker"

iex> NeoFaker.App.name(locale: :id_id)
"Garuda Web"

semver(opts \\ [])

iex> NeoFaker.App.semver()
"1.2.3"

iex> NeoFaker.App.semver(type: :pre_release)
"1.2.3-beta.1"

iex> NeoFaker.App.semver(type: :build)
"1.2.3+20250325"

iex> NeoFaker.App.semver(type: :pre_release_build)
"1.2.3-rc.1+20250325"

version()

iex> NeoFaker.App.version()
"1.2"

Blood

group()

iex> NeoFaker.Blood.group()
"B+"

type()

iex> NeoFaker.Blood.type()
"B"

Boolean

boolean(true_ratio \\ 50, opts \\ [])

iex> NeoFaker.Boolean.boolean()
false

iex> NeoFaker.Boolean.boolean(75)
true

iex> NeoFaker.Boolean.boolean(75, integer: true)
1

Color

cmyk(opts \\ [])

iex> NeoFaker.Color.cmyk()
{0, 25, 50, 100}

iex> NeoFaker.Color.cmyk(format: :w3c)
"cmyk(0%, 25%, 50%, 100%)"

NeoFaker.Color.hsl/1, NeoFaker.Color.hsla/1, NeoFaker.Color.rgb/1 and NeoFaker.Color.rgba/1 follow the same pattern, returning their respective color values in tuples or formatted strings.

hex(opts \\ [])

iex> NeoFaker.Color.hex()
"#613583"

iex> NeoFaker.Color.hex(format: :three_digit)
"#365"

keyword(opts \\ [])

iex> NeoFaker.Color.keyword()
"blueviolet"

iex> NeoFaker.Color.keyword(category: :basic)
"purple"

iex> NeoFaker.Color.keyword(locale: :id_id)
"ungu"

Crypto

md5(opts \\ [])

iex> NeoFaker.Crypto.md5()
"afc4c626c55e4166421d82732163857d"

iex> NeoFaker.Crypto.md5(case: :upper)
"AFC4C626C55E4166421D82732163857D"

NeoFaker.Crypto.sha1/1 and NeoFaker.Crypto.sha256/1 follow the same pattern, generating their respective hash types with the same formatting options.

Date

add(range \\ -365..365, opts \\ [])

iex> NeoFaker.Date.add()
~D[2025-03-25]

iex> NeoFaker.Date.add(0..31)
~D[2025-03-30]

iex> NeoFaker.Date.add(0..31, format: :iso8601)
"2025-03-25"

between(start \\ ~D[1970-01-01], finish \\ NaiveDateTime.to_date(NaiveDateTime.local_now()), opts \\ [])

iex> NeoFaker.Date.between()
~D[2025-03-25]

iex> NeoFaker.Date.between(~D[2020-01-01], ~D[2025-01-01])
~D[2022-08-17]

iex> NeoFaker.Date.between(~D[2025-03-25], ~D[2025-03-25], format: :iso8601)
"2025-03-25"

birthday(min_age \\ 18, max_age \\ 65, opts \\ [])

iex> NeoFaker.Date.birthday()
~D[1997-01-02]

iex> NeoFaker.Date.birthday(18, 65)
~D[1998-03-04]

iex> NeoFaker.Date.birthday(18, 65, format: :iso8601)
"1999-05-06"

Gravatar

display(email \\ nil, opts \\ [])

iex> NeoFaker.Gravatar.display()
"https://gravatar.com/avatar/<hashed_email>?d=identicon&s=80"

iex> NeoFaker.Gravatar.display("john.doe@example.com")
"https://gravatar.com/avatar/<hashed_email>?d=identicon&s=80"

iex> NeoFaker.Gravatar.display("john.doe@example.com", size: 100)
"https://gravatar.com/avatar/<hashed_email>?d=identicon&s=100"

iex> NeoFaker.Gravatar.display("john.doe@example.com", fallback: :monsterid)
"https://gravatar.com/avatar/<hashed_email>?d=monsterid&s=80"

HTTP

referrer_policy()

iex> NeoFaker.Http.referrer_policy()
"no-referrer"

request_method()

iex> NeoFaker.Http.request_method()
"GET"

status_code(opts \\ [])

iex> NeoFaker.Http.status_code()
"200 OK"

iex> NeoFaker.Http.status_code(type: :simple)
"200"

iex> NeoFaker.Http.status_code(group: :client_error)
"404 Not Found"

user_agent(opts \\ [])

iex> NeoFaker.Http.user_agent()
"Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0"

iex> NeoFaker.Http.user_agent(type: :browser)
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0"

iex> NeoFaker.Http.user_agent(type: :crawler)
"Mozilla/5.0 (compatible; Google-InspectionTool/1.0)"

Lorem

sentence(opts \\ [])

iex> NeoFaker.Lorem.paragraph()
"Suspendisse ac justo venenatis, tincidunt sapien nec, accumsan augue. Vestibulum urna
risus, egestas ut ultrices non, aliquet eget massa. Mauris id diam eget augue sagittis
convallis sit amet nec diam. Morbi ut blandit est, et placerat neque."

iex> NeoFaker.Lorem.paragraph(type: "meditations")
"Do the things external which fall upon thee distract thee? Give thyself time to learn
something new and good, and cease to be whirled around. But then thou must also avoid being
carried about the other way. For those too are triflers who have wearied themselves in life
by their activity, and yet have no object to which to direct every movement, and, in a word,
all their thoughts."

NeoFaker.Lorem.sentence/1 and NeoFaker.Lorem.word/1 follow the same pattern, supporting the same types and format options but generate different text lengths.

Number

between(min \\ 0, max \\ 100)

iex> NeoFaker.Number.between()
27

iex> NeoFaker.Number.between(1, 100)
28

iex> NeoFaker.Number.between(20, 100.0)
29.481745280074264

iex> NeoFaker.Number.between(10.0, 100.0)
29.481745280074264

digit()

iex> NeoFaker.Number.digit()
5

float(left_digit \\ 10..100, right_digit \\ 10_000..100_000)

iex> NeoFaker.Number.float()
30.94372

iex> NeoFaker.Number.float(1..9, 10..90)
1.44

Person

age(min \\ 0, max \\ 120)

iex> NeoFaker.Person.age()
44

iex> NeoFaker.Person.age(7, 44)
27

binary_gender(opts \\ [])

iex> NeoFaker.Person.binary_gender()
"Male"

iex> NeoFaker.Person.binary_gender(locale: :id_id)
"Perempuan"

NeoFaker.Person.non_binary_gender/1 and NeoFaker.Person.short_binary_gender/1 accept the same options and follow the same pattern, but generate different gender values.

first_name(opts \\ [])

iex> NeoFaker.Person.first_name()
"Julia"

iex> NeoFaker.Person.first_name(sex: :male)
"José"

iex> NeoFaker.Person.first_name(locale: :id_id)
"Jaka"

NeoFaker.Person.middle_name/1 and NeoFaker.Person.last_name/1 accept the same options and follow the same pattern, but generate middle or last names respectively.

full_name(opts \\ [])

iex> NeoFaker.Person.full_name()
"Abigail Bethany Crawford"

iex> NeoFaker.Person.full_name(sex: :male)
"Daniel Edward Fisher"

iex> NeoFaker.Person.full_name(middle_name: false)
"Gabriella Harrison"

prefix(opts \\ [])

iex> NeoFaker.Person.prefix()
"Mr."

iex> NeoFaker.Person.prefix(locale: :id_id)
"Tn."

NeoFaker.Person.suffix/1 accepts the same options and follows the same pattern, but generates name suffixes instead of prefixes.

Text

character(opts \\ [])

iex> NeoFaker.Text.character()
"a"

iex> NeoFaker.Text.character(type: :digit)
"0"

characters(number \\ 11, opts \\ [])

iex> NeoFaker.Text.characters()
"XfELJU1mRMg"

iex> NeoFaker.Text.characters(20, type: :alphabet_upper)
"BVAJHRGSCEVJFNYSWCJE"

emoji(opts \\ [])

iex> NeoFaker.Text.emoji()
"✨"

iex> NeoFaker.Text.emoji(category: :activities)
"🎉"

word()

iex> NeoFaker.Text.word()
"computer"

Time

add(range \\ -24..24, opts \\ [])

iex> NeoFaker.Time.add()
~T[15:22:10]

iex> NeoFaker.Time.add(-2..2, unit: :minute)
~T[07:23:10]

iex> NeoFaker.Time.add(0..10, format: :iso8601)
"15:22:10"

between(start \\ ~T[00:00:00], finish \\ ~T[23:59:59], opts \\ [])

iex> NeoFaker.Time.between()
~T[15:22:10]

iex> NeoFaker.Time.between(~T[00:00:00], ~T[23:59:59])
~T[19:30:11]

iex> NeoFaker.Time.between(~T[00:00:00], ~T[23:59:59], format: :iso8601)
"15:22:10"