Skip to content
On this page

Localization

Switching locales

Did you know Faker supports many different locales?
By default, when using import { faker } from '@faker-js/faker' actually every available locale that is supported by Faker will be loaded and you can switch the locale at runtime with faker.setLocale('de').

TIP

Alternatively you can also just use faker.locale = 'de' instead to switch the locale.

Individual localized packages

By default, Faker will include all locale data.
This might result in loading around 5 MB of data into memory and slow down startup times.

But we got your back!
When encountering such a problem in a test or production environment, you can use the individual localized packages.

ts
import { faker } from '@faker-js/faker/locale/de';

This will then just load the German locales with additional English locales as fallback. The fallback is required due to not all locales containing data for all features. If you encounter a missing locale entry in your selected language, feel free to open a Pull Request fixing that issue.

INFO

The English locales are around 600 KB in size.
All locales together are around 5 MB in size.

Available locales

LocaleName
af_ZAAfrikaans
arArabic
azAzerbaijani
czCzech
deGerman
de_ATGerman (Austria)
de_CHGerman (Switzerland)
elGreek
enEnglish
en_AUEnglish (Australia)
en_AU_ockerEnglish (Australia Ocker)
en_BORKEnglish (Bork)
en_CAEnglish (Canada)
en_GBEnglish (Great Britain)
en_GHEnglish (Ghana)
en_IEEnglish (Ireland)
en_INDEnglish (India)
en_NGNigeria (English)
en_USEnglish (United States)
en_ZAEnglish (South Africa)
esSpanish
es_MXSpanish (Mexico)
faFarsi
fiFinnish
frFrench
fr_BEFrançais (Belgique)
fr_CAFrench (Canada)
fr_CHFrench (Switzerland)
geGeorgian
heHebrew
hrHrvatski
huHungarian
hyArmenian
id_IDIndonesian
itItalian
jaJapanese
koKorean
lvLatvian
mkMacedonian
nb_NONorwegian
neNepalese
nlDutch
nl_BEDutch (Belgium)
plPolish
pt_BRPortuguese (Brazil)
pt_PTPortuguese (Portugal)
roRomanian
ruRussian
skSlovakian
svSwedish
trTurkish
ukUkrainian
urUrdu
viVietnamese
zh_CNChinese
zh_TWChinese (Taiwan)
zu_ZAZulu (South Africa)

Released under the MIT License.