| name | faker-templates |
| description | Reference for Faker.js template helpers available in api-mock-server response body definitions. Use when building YAML config files for api-mock-server and you need to know which faker helpers are available, what they produce, or how to use dynamic values from request context. |
Faker Templates (api-mock-server)
Template syntax uses {{helperName args}} double-curly-brace notation inside any string value in a YAML body definition.
Person
| Template | Example |
|---|
{{faker.person.fullName}} | Alice Johnson |
{{faker.person.firstName}} | Alice |
{{faker.person.lastName}} | Johnson |
{{faker.person.jobTitle}} | Senior Software Engineer |
Internet
String and ID
| Template | Example |
|---|
{{faker.string.uuid}} | 550e8400-e29b-41d4-a716-446655440000 |
{{faker.string.alphanumeric 8}} | k3mP9xQr |
Number
| Template | Example |
|---|
{{faker.number.int min=1 max=100}} | 42 |
{{faker.number.float min=0 max=1}} | 0.73 |
Date and Time
| Template | Example |
|---|
{{faker.date.past}} | 2024-03-15T08:22:11.000Z |
{{faker.date.recent}} | 2025-01-10T14:33:00.000Z |
{{faker.date.future}} | 2026-06-20T09:15:00.000Z |
{{faker.date.birthdate}} | 1988-07-22T00:00:00.000Z |
Commerce
| Template | Example |
|---|
{{faker.commerce.productName}} | Sleek Plastic Chair |
{{faker.commerce.price}} | 49.99 |
{{faker.commerce.department}} | Electronics |
Company
| Template | Example |
|---|
{{faker.company.name}} | Acme Corp |
{{faker.company.catchPhrase}} | Adaptive content-based middleware |
Text
| Template | Example |
|---|
{{faker.lorem.word}} | lorem |
{{faker.lorem.sentence}} | Lorem ipsum dolor sit amet. |
{{faker.lorem.paragraph}} | (full paragraph) |
Helpers
| Template | Example |
|---|
{{faker.helpers.arrayElement ["a" "b" "c"]}} | b |
Request Context
| Template | Description |
|---|
{{params.id}} | URL path parameter |
{{query.page}} | Query string value |
{{body.fieldName}} | Request body field (POST/PUT/PATCH) |
{{header.authorization}} | Request header value (lowercase name) |
Error handling
If a template is invalid or the helper does not exist, the value is replaced with [template error: description] and the server logs a warning. The request still succeeds with a 200 (or configured status code).
Notes
- Templates are evaluated fresh on every request - each call returns different Faker values
- Templates can be nested inside arrays and objects at any depth
- Template values are always strings in YAML - booleans and numbers from Faker are automatically coerced
- The sandbox does not have access to
process, require, eval, or any Node.js globals