from faker import Faker★The one import.Fakeris the class.fake = Faker()★A generator. Defaults toen_US.fake.name()★Call any provider method → a fresh value.Faker('fr_FR')One locale → localized data.Faker(['en_US','ja_JP'])Multi-locale: each call picks one at random.Faker(use_weighting=False)Uniform & faster; drop real-world frequency.fake.format('name')Dispatch by string — same asfake.name().
fake.name()★'Allison Hill' — full name.fake.first_name()★'Jeffrey'fake.last_name()★'Doyle'fake.name_male()Gendered: alsoname_female().fake.first_name_female()Gendered given names, both sexes.fake.prefix()'Mr.' ·suffix()→ 'MD'
fake.email()★'jason41@example.net' — safe TLD.fake.safe_email()Always@example.*— never a real domain.fake.email(domain='acme.com')Pin the domain. Alsofree_email,company_email.fake.user_name()★'nadams'fake.url()'https://www.taylor-mcgee.net/'fake.domain_name()'walter.biz' ·slug(),hostname().fake.ipv4()★ipv4_private(),ipv4_public(),ipv6().fake.mac_address()'dc:70:46:fc:2e:18'fake.image_url()Placeholder URL ·uri(),port_number().
fake.address()★Full multi-line postal address.fake.street_address()'5940 Herrera Lane'fake.city()★'New Kellystad'fake.state()'Oregon' ·state_abbr()→ 'ID'fake.zipcode()★'92850' · aliaspostcode().fake.country()'Aruba' ·country_code()→ 'HR'fake.latitude()Alsolongitude(),building_number().
fake.phone_number()★'289-332-5288x0957'fake.msisdn()13-digit mobile number (GSM).fake.country_calling_code()'+256'fake.latlng()(Decimal('62.6'), Decimal('39.5'))fake.location_on_land()(lat, lng, place, country, tz) on real land.fake.coordinate()A single bounded coordinate value.
fake.company()★'Baker PLC'fake.company_suffix()'Group', 'LLC', 'PLC' …fake.catch_phrase()'Extended needs-based system engine'fake.bs()'drive 24/365 content' — corporate speak.fake.job()★'Oceanographer'
fake.word()'difficult'fake.words(nb=3)['much','rich','think'] · addunique=True.fake.sentence()★nb_words=6by default.fake.paragraph()nb_sentences=3. Alsoparagraphs().fake.text(max_nb_chars=200)★Bounded blob of lorem.fake.sentence(ext_word_list=[…])Swap in your own word list.
fake.date()★'1994-10-13' (str).time()too.fake.date_time()datetimeobject ·iso8601()for a str.fake.date_of_birth()★minimum_age=,maximum_age=.fake.date_between('-30d','today')★Bounded range; relative strings work.fake.future_date()past_date(),date_this_year(),date_this_month().fake.unix_time()Epoch float ·day_of_week(),month_name(),year().
fake.random_int(min=0, max=99)★Inclusive;step=optional.fake.pyint()pyfloat(left_digits=, right_digits=, positive=).fake.pydecimal(…)ExactDecimalfor money-like fields.fake.pybool()pystr(),pylist(),pydict(),pytuple(),pyset().fake.random_element(('a','b','c'))★Your own pool. Dict → weighted:{'a':0.8,'b':0.2}.fake.random_elements(length=2)unique=Truefor no repeats ·random_sample().fake.random_choices(…)With replacement;random_digit(),random_letter().
fake.uuid4()★'79a28903-…' — great for keys.fake.password()★length=,special_chars=,digits=…fake.boolean(chance_of_getting_true=50)Weighted True/False.fake.sha256()md5(),sha1()— hex digests.fake.json()csv(),xml(),binary()— whole documents.fake.file_name()file_path(),file_extension(),mime_type().
fake.credit_card_number()★Luhn-valid;credit_card_provider(),_expire(),_security_code().fake.credit_card_full()Multi-line: name + number + expiry + CVC.fake.iban()bban(),swift(),bank_country().fake.currency_code()'BMD' ·currency(),cryptocurrency(),pricetag().fake.ssn()Locale-specific national ID (en_US→ SSN).
fake.hex_color()'#9ba897' ·color_name(),rgb_color(),safe_color_name().fake.ean13()Barcodes:ean(),ean8().fake.isbn13()isbn10()·doi()for academic IDs.fake.license_plate()vin()— vehicle identifiers.fake.user_agent()chrome(),firefox(),safari().fake.emoji()A random emoji character.
fake.simple_profile()★Dict: username, name, sex, address, mail, birthdate.fake.profile()Full dict — job, company, ssn, blood group, website, coords …fake.profile(fields=['name','mail'])Pick only the keys you need.fake.profile(sex='F')Force the gender of the record.
fake.numerify('###-##')#→digit,%→1-9,!→digit-or-blank.fake.lexify('????')?→ a random letter.fake.bothify('??-####')★Letters and digits ·letters='ABC'.fake.hexify('^^:^^')^→ a hex digit.fake.pystr_format('ID-{{random_int}}-##'){{method}}interpolates another fake.
Faker.seed(0)★Classmethod — seeds the shared RNG for all instances.fake.seed_instance(4321)Give this one generator its own isolated RNG.fake.randomThe underlyingrandom.Random—getstate()/setstate().# pin Faker==40.36.0noteSame seed reproduces only within a patch version — pin if you hardcode outputs.
fake.unique.email()★No repeats for this instance — ideal for keys.fake.unique.clear()Forget seen values & start fresh.fake.optional.name(prob=0.5)The value, orNoneat chance1-prob.fake.unique['en_US'].first_name()Unique within one locale of a multi-locale generator.fake.unique.boolean()raisesLow cardinality →UniquenessException. Never unique-ify small pools.
from faker.providers import BaseProviderSubclass, add methods, then register.fake.add_provider(MyProvider)★Its methods now live onfakelike any other.self.random_element(self.mylist)Inside a provider, reuse the base helpers.DynamicProvider(provider_name=…, elements=[…])List-driven provider — no subclass needed.
def test_x(faker): …★Built-infakerfixture: session-scoped, seed0.def faker_seed(): return 12345Override seed via a fixture;faker_session_locale()for locale.factory.Faker('name')factory_boy field:factory.Faker('sentence', nb_words=4).python -m faker -l de_DE -r 5 nameCLI:-rrepeat,-ofile,-iimport a provider.