NeoFaker
NeoFaker generates realistic fake data for Elixir tests, database seeds, and local development.
Requirements
- Erlang:
28.0or newer - Elixir:
1.18.4-otp-28or newer
Installation
Add NeoFaker to your mix.exs dependencies:
def deps do
[
{:neo_faker, "~> 0.15.0", only: [:dev, :test]}
]
end
Then fetch it:
mix deps.get
See the Getting Started Guide for the full setup walkthrough, including test-suite configuration.
Configuration
Set a default locale in config/config.exs:
config :neo_faker, locale: :default
If the requested locale isn't available, NeoFaker falls back to :default (generic English (US)
data). NeoFaker.Locale.set/1 changes the locale for the current process only. It's safe to use
inside async: true tests, since it can't affect other tests running at the same time.
Using with Phoenix Framework
For a Phoenix app, set the locale in config/dev.exs and config/test.exs instead of the
top-level config.exs. Then call NeoFaker.start() in test/test_helper.exs.
If you also use NeoFaker inside test/support/factory.ex to build fake Ecto.Schema structs for
your tests, see the Ecto Test Factories
guide. It covers wiring NeoFaker into the factory pattern from Ecto's own docs, and how to keep
factory-generated values unique where your schema requires it.
Usage
iex> NeoFaker.Person.full_name()
"Abigail Bethany Crawford"
iex> NeoFaker.Internet.email()
"jose@example.com"
iex> NeoFaker.Address.city(locale: :id_id)
"Sigi"
iex> NeoFaker.Date.past(30)
~D[2025-02-25]
iex> NeoFaker.Color.hex()
"#613583"
Documentation
- Getting Started: installation, configuration, and first steps.
- API Reference: full module and function documentation.
- Cheat Sheet: one-page reference of every domain generator function, with examples.
- Locale Cheat Sheet: one-page reference of locale-exclusive generators, grouped by locale.
- Supported Locales: available locales and how locale resolution works.
- Ecto Test Factories: using NeoFaker as the data source in an Ecto-based factory module.
- Adding a Locale: contributor guide for submitting a new locale as a pull request.
- Changelog: release history.
Contributing
Issues and pull requests are welcome on GitHub.
License
Licensed under the MIT License.