Docs Faker Functions Reference

Faker Reference for Mockarty

Table of Contents

  1. Overview
  2. Address
  3. DateTime
  4. Internet
  5. Text
  6. Payment
  7. Person
  8. Phone
  9. ID and Hashes
  10. Business
  11. Russian
  12. Common Types
  13. Math Functions
  14. Go Template Syntax
  15. Practical Examples

Overview

Faker in Mockarty generates random test data for dynamic mock responses. Every field listed below is a zero-argument accessor available through JPath as $.fake.FieldName.

{
  "response": {
    "payload": {
      "id": "$.fake.UUID",
      "name": "$.fake.FirstName",
      "email": "$.fake.Email",
      "createdAt": "$.fake.RFC3339"
    }
  }
}

Important: JPath mode does NOT support parameterized calls. $.fake.UUID is correct; $.fake.IntBetween(1, 100) will NOT work. Use Math Functions ($.increment, $.sum, $.multiply, $.subtract) for arithmetic.

Tip: Reusing generated values. Every $.fake.* call generates a new random value each time it is evaluated. If you need the same generated value in multiple places (e.g., the same UUID in both the response and an extraction), first extract it into a Mock Store (mStore), then reference it via $.mS.key:

{
  "extract": {
    "mStore": {
      "generatedId": "$.fake.UUID"
    }
  },
  "response": {
    "payload": {
      "id": "$.mS.generatedId",
      "link": "https://example.com/items/$.mS.generatedId"
    }
  }
}

This way generatedId is created once and reused consistently.


Address

Function Description Example
$.fake.Latitude Random latitude 81.12195
$.fake.Longitude Random longitude -84.38158
$.fake.City City name "New York"
$.fake.Country Country name "United States"
$.fake.CountryCode ISO country code "US"
$.fake.State US state name "California"
$.fake.StreetAddress Street number and name "4821 Maple Avenue"
$.fake.ZipCode 5-digit zip code "07432"
$.fake.Address Full address (street, city, state, zip) "4821 Maple Avenue, New York, California 07432"
{
  "response": {
    "payload": {
      "location": {
        "address": "$.fake.Address",
        "city": "$.fake.City",
        "state": "$.fake.State",
        "zip": "$.fake.ZipCode",
        "country": "$.fake.Country",
        "countryCode": "$.fake.CountryCode",
        "coordinates": {
          "lat": "$.fake.Latitude",
          "lng": "$.fake.Longitude"
        }
      }
    }
  }
}

DateTime

Function Description Example
$.fake.UnixTime Unix timestamp (seconds) 1197930901
$.fake.Date Random date (YYYY-MM-DD) "1982-02-27"
$.fake.TimeString Random time (HH:MM:SS) "03:10:25"
$.fake.MonthName Month name "February"
$.fake.YearString Year as string "1994"
$.fake.DayOfWeek Day of week name "Sunday"
$.fake.DayOfMonth Day of month "20"
$.fake.Timestamp Full timestamp (YYYY-MM-DD HH:MM:SS) "1973-06-21 14:50:46"
$.fake.RFC3339 Current time in RFC 3339 format "2024-01-15T14:30:45Z"
$.fake.Century Century (Roman numeral) "IV"
$.fake.Timezone Timezone identifier "Asia/Jakarta"
$.fake.TimePeriod AM or PM "PM"
{
  "response": {
    "payload": {
      "createdAt": "$.fake.RFC3339",
      "date": "$.fake.Date",
      "time": "$.fake.TimeString",
      "unixTs": "$.fake.UnixTime",
      "month": "$.fake.MonthName",
      "year": "$.fake.YearString",
      "dayOfWeek": "$.fake.DayOfWeek",
      "dayOfMonth": "$.fake.DayOfMonth",
      "fullTimestamp": "$.fake.Timestamp",
      "timezone": "$.fake.Timezone",
      "period": "$.fake.TimePeriod"
    }
  }
}

Internet

Function Description Example
$.fake.Email Email address "mJBJtbv@OSAaT.com"
$.fake.MacAddress MAC address "cd:65:e1:d4:76:c6"
$.fake.DomainName Domain name "FWZcaRE.org"
$.fake.URL URL "https://www.oEuqqAY.org/QgqfOhd"
$.fake.Username Username "lVxELHS"
$.fake.IPv4 IPv4 address "99.23.42.63"
$.fake.IPv6 IPv6 address "975c:fb2c:2133:fbdd:beda:282e:1e0a:ec7d"
$.fake.Password Random password string "dfJdyHGuVkHBgnHLQQgpINApynzexnRpgIKBpiIjpTP"
$.fake.UserAgent Browser User-Agent string "Mozilla/5.0 (Windows NT 10.0; Win64; x64) ..."
$.fake.Color Color name "Teal"
$.fake.HexColor Hex color code "#3a2f1c"
{
  "response": {
    "payload": {
      "contact": {
        "email": "$.fake.Email",
        "website": "$.fake.URL"
      },
      "technical": {
        "ip": "$.fake.IPv4",
        "ipv6": "$.fake.IPv6",
        "mac": "$.fake.MacAddress",
        "userAgent": "$.fake.UserAgent",
        "domain": "$.fake.DomainName"
      },
      "style": {
        "color": "$.fake.Color",
        "hex": "$.fake.HexColor"
      }
    }
  }
}

Text

Function Description Example
$.fake.Word Random word "nesciunt"
$.fake.Sentence Random sentence "Consequatur perferendis voluptatem accusantium."
$.fake.Paragraph Random paragraph (multiple sentences) "Aut consequatur sit perferendis ..."
$.fake.Letter Single uppercase letter (A-Z) "M"
{
  "response": {
    "payload": {
      "title": "$.fake.Sentence",
      "description": "$.fake.Paragraph",
      "keyword": "$.fake.Word",
      "initial": "$.fake.Letter"
    }
  }
}

Payment

Function Description Example
$.fake.CCType Credit card type "American Express"
$.fake.CCNumber Credit card number "373641309057568"
$.fake.Currency Currency code "USD"
$.fake.AmountWithCurrency Amount with currency code "USD 49257.100"
$.fake.Price Price with two decimal places "123.45"
{
  "response": {
    "payload": {
      "payment": {
        "cardType": "$.fake.CCType",
        "cardNumber": "$.fake.CCNumber",
        "currency": "$.fake.Currency",
        "total": "$.fake.AmountWithCurrency",
        "price": "$.fake.Price"
      }
    }
  }
}

Person

Function Description Example
$.fake.TitleMale Male title "Mr."
$.fake.TitleFemale Female title "Mrs."
$.fake.FirstName First name (any gender) "Whitney"
$.fake.FirstNameMale Male first name "Kenny"
$.fake.FirstNameFemale Female first name "Jana"
$.fake.LastName Last name "Rohan"
$.fake.Name Full name with title "Mrs. Casandra Kiehn"
$.fake.Gender Gender string "Male" or "Female"
{
  "response": {
    "payload": {
      "user": {
        "title": "$.fake.TitleMale",
        "firstName": "$.fake.FirstName",
        "lastName": "$.fake.LastName",
        "fullName": "$.fake.Name",
        "gender": "$.fake.Gender"
      }
    }
  }
}

Phone

Function Description Example
$.fake.PhoneNumber Phone number "201-886-0269"
$.fake.Phone Alias for PhoneNumber "201-886-0269"
$.fake.TollFreePhoneNumber Toll-free phone number "(777) 831-964572"
$.fake.E164PhoneNumber Phone in E.164 format "+724891571063"
{
  "response": {
    "payload": {
      "contact": {
        "phone": "$.fake.Phone",
        "tollFree": "$.fake.TollFreePhoneNumber",
        "international": "$.fake.E164PhoneNumber"
      }
    }
  }
}

ID and Hashes

Function Description Example
$.fake.UUID UUID v4 with hyphens "8f8e4463-9560-4a38-9b0c-ef24481e4e27"
$.fake.UUIDDigit UUID without hyphens "90ea6479fd0e4940af741f0a87596b73"
$.fake.JWT Realistic JWT (header.payload.signature) "eyJhbGciOiJIUzI1NiIs..."
$.fake.MD5 MD5 hash (32 hex chars) "5d41402abc4b2a76b9719d911017c592"
$.fake.SHA256 SHA-256 hash (64 hex chars) "e3b0c44298fc1c149afbf4c8996fb924..."
{
  "response": {
    "payload": {
      "id": "$.fake.UUID",
      "shortId": "$.fake.UUIDDigit",
      "token": "$.fake.JWT",
      "checksum": "$.fake.MD5",
      "hash": "$.fake.SHA256"
    }
  }
}

Business

Function Description Example
$.fake.Company Company name "Stark Industries"
$.fake.JobTitle Job title "Software Engineer"
{
  "response": {
    "payload": {
      "employee": {
        "company": "$.fake.Company",
        "jobTitle": "$.fake.JobTitle"
      }
    }
  }
}

Russian

Function Description Example
$.fake.RussianFirstNameMale Russian male first name "Александр"
$.fake.RussianLastNameMale Russian male last name "Иванов"
$.fake.RussianFirstNameFemale Russian female first name "Анна"
$.fake.RussianLastNameFemale Russian female last name "Иванова"
{
  "response": {
    "payload": {
      "russianUser": {
        "firstName": "$.fake.RussianFirstNameMale",
        "lastName": "$.fake.RussianLastNameMale"
      },
      "russianUserFemale": {
        "firstName": "$.fake.RussianFirstNameFemale",
        "lastName": "$.fake.RussianLastNameFemale"
      }
    }
  }
}

Common Types

Function Description Example
$.fake.Bool Random boolean true or false
$.fake.String Random word (same as Word) "lorem"
$.fake.Number Random integer (0 to 999999) 482731
$.fake.Int Random integer (0 to 999999) 348217
$.fake.Float Random float (0 to 1000) 472.839
$.fake.Digit Single digit (0-9) as string "7"
$.fake.PositiveInt Large positive integer 4823947291847
$.fake.NegativeInt Negative integer -2839174
$.fake.Base64 Base64-encoded random bytes "dGVzdCBiYXNlNjQ="
$.fake.Duration Duration string in seconds "1842s"
{
  "response": {
    "payload": {
      "isActive": "$.fake.Bool",
      "label": "$.fake.String",
      "count": "$.fake.Number",
      "score": "$.fake.Int",
      "rate": "$.fake.Float",
      "code": "$.fake.Digit",
      "positiveId": "$.fake.PositiveInt",
      "offset": "$.fake.NegativeInt",
      "encoded": "$.fake.Base64",
      "ttl": "$.fake.Duration"
    }
  }
}

Math Functions

These are NOT part of $.fake.* but are standalone JPath math expressions. They accept JPath expressions or literal numbers as arguments.

Function Description Example
$.increment(expr) Increment a numeric value by 1 $.increment($.gS.counter)
$.sum(a, b) Sum of two values $.sum($.gS.price, 10)
$.multiply(a, b) Product of two values $.multiply($.gS.quantity, $.gS.unitPrice)
$.subtract(a, b) Difference of two values $.subtract($.gS.total, $.gS.discount)

Arguments can be:

  • Literal numbers: 5, 3.14
  • JPath expressions: $.gS.counter, $.cS.amount
  • Expressions with fallback: $.gS.counter || 0 (use 0 if the store key is missing)
{
  "response": {
    "payload": {
      "nextId": "$.increment($.gS.lastId || 0)",
      "total": "$.sum($.gS.subtotal, $.gS.tax)",
      "extendedPrice": "$.multiply($.gS.quantity, $.gS.unitPrice)",
      "balance": "$.subtract($.gS.credit, $.gS.debit)"
    }
  }
}

Go Template Syntax

When using Go templates (.tmpl files or goTemplate: true), Faker is available via the fake function which returns a Faker object. Call zero-argument methods on it:

{
  "id": "{{(fake).UUID}}",
  "name": "{{(fake).FirstName}}",
  "email": "{{(fake).Email}}",
  "createdAt": "{{(fake).RFC3339}}"
}

The (fake) call returns a Faker struct, then .MethodName calls the corresponding method. For example:

{
  "user": {
    "id": "{{(fake).UUID}}",
    "firstName": "{{(fake).FirstName}}",
    "lastName": "{{(fake).LastName}}",
    "phone": "{{(fake).PhoneNumber}}",
    "isAdmin": {{(fake).Bool}},
    "createdAt": "{{(fake).RFC3339}}"
  }
}

Important: Not all JPath fields have Go Template methods. Only the methods listed in the table below are available in Go Template mode. JPath-only fields (like City, Company, MD5, Phone, Price, etc.) are populated on the JpathTemplateFakeData struct and are NOT callable via {{(fake).FieldName}}.

Available Go Template Methods

Method Return Type Category
{{(fake).Latitude}} float64 Address
{{(fake).Longitude}} float64 Address
{{(fake).GetRealAddress}} object Address (Go Template only)
{{(fake).UnixTime}} int64 DateTime
{{(fake).Date}} string DateTime
{{(fake).TimeString}} string DateTime
{{(fake).MonthName}} string DateTime
{{(fake).YearString}} string DateTime
{{(fake).DayOfWeek}} string DateTime
{{(fake).DayOfMonth}} string DateTime
{{(fake).Timestamp}} string DateTime
{{(fake).RFC3339}} string DateTime
{{(fake).Century}} string DateTime
{{(fake).Timezone}} string DateTime
{{(fake).TimePeriod}} string DateTime
{{(fake).Email}} string Internet
{{(fake).MacAddress}} string Internet
{{(fake).DomainName}} string Internet
{{(fake).URL}} string Internet
{{(fake).Username}} string Internet
{{(fake).IPv4}} string Internet
{{(fake).IPv6}} string Internet
{{(fake).Password}} string Internet
{{(fake).Word}} string Text
{{(fake).Sentence}} string Text
{{(fake).Paragraph}} string Text
{{(fake).CCType}} string Payment
{{(fake).CCNumber}} string Payment
{{(fake).Currency}} string Payment
{{(fake).AmountWithCurrency}} string Payment
{{(fake).TitleMale}} string Person
{{(fake).TitleFemale}} string Person
{{(fake).FirstName}} string Person
{{(fake).FirstNameMale}} string Person
{{(fake).FirstNameFemale}} string Person
{{(fake).LastName}} string Person
{{(fake).Name}} string Person
{{(fake).PhoneNumber}} string Phone
{{(fake).TollFreePhoneNumber}} string Phone
{{(fake).E164PhoneNumber}} string Phone
{{(fake).UUID}} string ID
{{(fake).UUIDDigit}} string ID
{{(fake).JWT}} string ID
{{(fake).Bool}} bool Common
{{(fake).String}} string Common
{{(fake).PositiveInt}} int64 Common
{{(fake).NegativeInt}} int64 Common
{{(fake).RussianFirstNameMale}} string Russian
{{(fake).RussianLastNameMale}} string Russian
{{(fake).RussianFirstNameFemale}} string Russian
{{(fake).RussianLastNameFemale}} string Russian

JPath-Only Fields (NOT Available in Go Template)

The following fields are available only via JPath $.fake.* and do NOT have corresponding Go Template methods:

City, Country, CountryCode, State, StreetAddress, ZipCode, Address, UserAgent, Color, HexColor, Letter, Digit, Gender, Phone, Number, Int, Float, Base64, Duration, Price, Company, JobTitle, MD5, SHA256

All listed fields are fully populated and return realistic values in JPath mode.

Go Template only: GetRealAddress() returns a real address object with fields Street, City, State, and Zip. This method is only available in Go Template mode via {{(fake).GetRealAddress}} – it is NOT accessible via JPath $.fake.GetRealAddress.

{
  "address": {
    "street": "{{(fake).GetRealAddress.Street}}",
    "city": "{{(fake).GetRealAddress.City}}",
    "state": "{{(fake).GetRealAddress.State}}",
    "zip": "{{(fake).GetRealAddress.Zip}}"
  }
}

Practical Examples

Complete User Profile

{
  "id": "user-profile",
  "http": {
    "route": "/api/users/profile"
  },
  "response": {
    "payload": {
      "user": {
        "id": "$.fake.UUID",
        "username": "$.fake.Username",
        "firstName": "$.fake.FirstName",
        "lastName": "$.fake.LastName",
        "fullName": "$.fake.Name",
        "gender": "$.fake.Gender",
        "email": "$.fake.Email",
        "phone": "$.fake.Phone",
        "address": {
          "street": "$.fake.StreetAddress",
          "city": "$.fake.City",
          "state": "$.fake.State",
          "zip": "$.fake.ZipCode",
          "country": "$.fake.Country",
          "lat": "$.fake.Latitude",
          "lng": "$.fake.Longitude"
        },
        "work": {
          "company": "$.fake.Company",
          "jobTitle": "$.fake.JobTitle"
        },
        "notifications": "$.fake.Bool",
        "createdAt": "$.fake.RFC3339",
        "ipAddress": "$.fake.IPv4",
        "userAgent": "$.fake.UserAgent"
      }
    }
  }
}

Financial Transaction

{
  "id": "financial-transaction",
  "http": {
    "route": "/api/transactions"
  },
  "response": {
    "payload": {
      "transaction": {
        "id": "$.fake.UUID",
        "type": "payment",
        "status": "completed",
        "amount": "$.fake.Price",
        "currency": "$.fake.Currency",
        "total": "$.fake.AmountWithCurrency",
        "card": {
          "type": "$.fake.CCType",
          "number": "$.fake.CCNumber"
        },
        "merchant": {
          "name": "$.fake.Company",
          "address": "$.fake.Address"
        },
        "customer": {
          "name": "$.fake.Name",
          "email": "$.fake.Email",
          "phone": "$.fake.Phone"
        },
        "hash": "$.fake.SHA256",
        "authCode": "$.fake.MD5",
        "processedAt": "$.fake.RFC3339"
      }
    }
  }
}

Complete Function List (Quick Reference)

All 74 available $.fake.* fields at a glance:

# Field Category
1 Latitude Address
2 Longitude Address
3 City Address
4 Country Address
5 CountryCode Address
6 State Address
7 StreetAddress Address
8 ZipCode Address
9 Address Address
10 UnixTime DateTime
11 Date DateTime
12 TimeString DateTime
13 MonthName DateTime
14 YearString DateTime
15 DayOfWeek DateTime
16 DayOfMonth DateTime
17 Timestamp DateTime
18 RFC3339 DateTime
19 Century DateTime
20 Timezone DateTime
21 TimePeriod DateTime
22 Email Internet
23 MacAddress Internet
24 DomainName Internet
25 URL Internet
26 Username Internet
27 IPv4 Internet
28 IPv6 Internet
29 Password Internet
30 UserAgent Internet
31 Color Internet
32 HexColor Internet
33 Word Text
34 Sentence Text
35 Paragraph Text
36 Letter Text
37 CCType Payment
38 CCNumber Payment
39 Currency Payment
40 AmountWithCurrency Payment
41 Price Payment
42 TitleMale Person
43 TitleFemale Person
44 FirstName Person
45 FirstNameMale Person
46 FirstNameFemale Person
47 LastName Person
48 Name Person
49 Gender Person
50 PhoneNumber Phone
51 Phone Phone
52 TollFreePhoneNumber Phone
53 E164PhoneNumber Phone
54 UUID ID & Hashes
55 UUIDDigit ID & Hashes
56 JWT ID & Hashes
57 MD5 ID & Hashes
58 SHA256 ID & Hashes
59 Company Business
60 JobTitle Business
61 RussianFirstNameMale Russian
62 RussianLastNameMale Russian
63 RussianFirstNameFemale Russian
64 RussianLastNameFemale Russian
65 Bool Common
66 String Common
67 Number Common
68 Int Common
69 Float Common
70 Digit Common
71 PositiveInt Common
72 NegativeInt Common
73 Base64 Common
74 Duration Common

See Also

  • JsonPath Guide – query language used together with Faker for dynamic responses
  • Store Systems – persist Faker-generated data across mock invocations
  • API Reference – complete REST API for creating mocks with Faker
  • Web UI Guide – create mocks with Faker visually in the Constructor
  • Quick Start – get started with your first Faker-powered mock