Skip to content

Faker Integration

The generator supports Faker providers via the faker hint in arg.properties. This gives you access to hundreds of realistic data generators for names, emails, addresses, phone numbers, and more.

Faker is included as a core dependency -- no extra install needed.

Simple usage

Pass the Faker method name as a string:

{
  "name": "customerName",
  "type": "string",
  "arg.properties": { "faker": "name" }
}

Common methods

Method Example output
name "John Smith"
first_name "Sarah"
last_name "Williams"
email "j.doe@example.com"
phone_number "+1-555-123-4567"
address "123 Main St, Springfield"
city "Cape Town"
country "South Africa"
company "Acme Corp"
job "Software Engineer"
url "https://example.com"
iban "DE89370400440532013000"
credit_card_number "4111111111111111"
date_of_birth "1985-03-12"
text "Lorem ipsum..."
sentence "The quick brown fox."
uuid4 "a1b2c3d4-..."
currency_code "ZAR"
color_name "teal"
user_agent "Mozilla/5.0..."
ipv4 "192.168.1.1"
mac_address "00:1B:44:11:3A:B7"

See the full list at Faker Providers.

With arguments, the short way

args, kwargs and locale can sit next to a string-form faker hint in the same arg.properties block. An object-valued args is passed as keyword arguments:

{
  "name": "cardLast4",
  "type": "string",
  "arg.properties": { "faker": "numerify", "args": { "text": "####" } }
}

A list-valued args is passed positionally instead:

{
  "name": "accountNumber",
  "type": "string",
  "arg.properties": { "faker": "bothify", "args": ["###-???-####"] }
}

Before 0.4.1

Siblings were silently ignored, so {"faker": "numerify", "args": {"text": "####"}} ran numerify() with its default "###" and produced three digits instead of four. avro-datagen validate now flags args, kwargs or locale written without a sibling faker.

Advanced usage

Pass a dict with method, args, kwargs, and/or locale. This is the explicit form of the same thing — use it when you prefer the call to be one self-contained object:

With arguments

{
  "name": "accountNumber",
  "type": "string",
  "arg.properties": {
    "faker": { "method": "bothify", "args": ["###-???-####"] }
  }
}

With keyword arguments

{
  "name": "age",
  "type": "int",
  "arg.properties": {
    "faker": { "method": "random_int", "kwargs": { "min": 18, "max": 85 } }
  }
}

With locale

Generate locale-specific data:

{
  "name": "customerName",
  "type": "string",
  "arg.properties": {
    "faker": { "method": "name", "locale": "af_ZA" }
  }
}
{
  "name": "japaneseAddress",
  "type": "string",
  "arg.properties": {
    "faker": { "method": "address", "locale": "ja_JP" }
  }
}

Combining with rules

Use Faker inside conditional rules:

"arg.properties": {
  "rules": [
    {
      "when": { "field": "country", "equals": "ZA" },
      "then": { "faker": { "method": "name", "locale": "af_ZA" } }
    },
    {
      "when": { "field": "country", "equals": "JP" },
      "then": { "faker": { "method": "name", "locale": "ja_JP" } }
    }
  ]
}

Seed behaviour

When using --seed, Faker output is also seeded via seed_instance(), making all generated values — including Faker fields — fully deterministic and reproducible across runs.