Function Reference
JsonFabrica templates generate values by calling built-in functions inside placeholders, using this syntax:
<functionName(arg1, arg2, ...)>This page documents every function currently available (25 total), in the order they typically appear when building a template.
Reusing a result later in the same template
Almost every function below also accepts one optional extra argument at the end of its normal parameter list — a variable name. When supplied, the function's result is also stored under that name, so you can retrieve the exact same value again later in the same template with <getVar(name)>. This applies to every function except getRandomElement, createSeq, setVar, and getVar themselves, which already have their own variable-related behavior.
Cost tiers
Each function is labeled with a relative cost category. Most functions are lightweight (in-memory) — cheap, per-call computation. A small number of functions are stateful (sequence/context-backed) — they read or write durable, cross-call state (such as a sequence counter) and are billed at a heavier cost tier. See how credits work for how these categories translate into usage cost.
| Function | Signature | Cost tier |
|---|---|---|
| createSeq | createSeq(name, type?, start?, step?) | stateful |
| getSeq | getSeq(name) | stateful |
| getVar | getVar(name) | lightweight |
| setVar | setVar(name, value) | lightweight |
| getRandomName | getRandomName(locale?) | lightweight |
| getRandomSurname | getRandomSurname(locale?) | lightweight |
| getRandomFullName | getRandomFullName(locale?) | lightweight |
| getRandomEmail | getRandomEmail(domain?) | lightweight |
| getRandomNumber | getRandomNumber(min?, max?, decimals?) | lightweight |
| getRandomBoolean | getRandomBoolean(trueProbability?) | lightweight |
| getRandomTextWithSpaces | getRandomTextWithSpaces(minLen, maxLen) | lightweight |
| getRandomElement | getRandomElement(...values) | lightweight |
| getRandomDate | getRandomDate(from?, to?) | lightweight |
| getRandomStreet | getRandomStreet(locale?) | lightweight |
| getRandomCity | getRandomCity(locale?) | lightweight |
| getRandomCountry | getRandomCountry() | lightweight |
| getRandomAddress | getRandomAddress(locale?) | lightweight |
| appendBefore | appendBefore(char, value, totalLength) | lightweight |
| appendAfter | appendAfter(char, value, totalLength) | lightweight |
| toUpperCase | toUpperCase(value) | lightweight |
| toLowerCase | toLowerCase(value) | lightweight |
| formatDate | formatDate(value, pattern) | lightweight |
| formatNumber | formatNumber(value, decimals, decimalSeparator?, thousandsSeparator?) | lightweight |
| getParam | getParam(name, default?) | lightweight |
| getContext | getContext(name) | stateful |
1. createSeq(name, type?, start?, step?)
statefulDeclares a named counter ("sequence") that you can then draw values from with getSeq. This is a setup step — it doesn't produce a value by itself.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| name | string | Yes | — |
| type | 'number' | 'string' | 'uuid' | No | 'number' |
| start | number | No | 0 |
| step | number | No | 1 |
<createSeq('orderNo', 'number', 1000, 1)>2. getSeq(name)
statefulReturns the next value from a sequence you've already declared with createSeq, advancing it each time it's called.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| name | string | Yes | — |
<getSeq('orderNo')>3. getVar(name)
lightweightReads back a value previously stored under a variable name — either earlier in the same template, or a shared variable available across your account.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| name | string | Yes | — |
<getVar('customerName')>4. setVar(name, value)
lightweightStores a value under a variable name so it can be read back later in the same template with getVar.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| name | string | Yes | — |
| value | any | Yes | — |
<setVar('discount', 10)>5. getRandomName(locale?)
lightweightReturns a random first name.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| locale | string | No | 'en' |
<getRandomName('en')>6. getRandomSurname(locale?)
lightweightReturns a random surname.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| locale | string | No | 'en' |
<getRandomSurname()>7. getRandomFullName(locale?)
lightweightReturns a random full name (first name and surname together).
| Param | Type | Required | Default / notes |
|---|---|---|---|
| locale | string | No | 'en' |
<getRandomFullName('en')>8. getRandomEmail(domain?)
lightweightReturns a synthetic, realistic-looking email address built from random names.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| domain | string | No | random from a built-in list |
<getRandomEmail('example.com')>9. getRandomNumber(min?, max?, decimals?)
lightweightReturns a random number within a range — an integer by default, or a decimal number if requested.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| min | number | No | 0 |
| max | number | No | 100 |
| decimals | number | No | 0 |
<getRandomNumber(1, 5, 0)>10. getRandomBoolean(trueProbability?)
lightweightReturns a random true/false value.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| trueProbability | number (0–1) | No | 0.5 |
<getRandomBoolean(0.7)>11. getRandomTextWithSpaces(minLen, maxLen)
lightweightGenerates random placeholder-style text within a given length range.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| minLen | number | Yes | — |
| maxLen | number | Yes | must be ≥ minLen |
<getRandomTextWithSpaces(10, 20)>12. getRandomElement(...values)
lightweightPicks one random value out of a list. Two ways to use it: pass a list of literal values directly, or pass the name of a variable that holds an array.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| values | any[] | variable name | Yes | pool of values, or a single variable name referencing an array |
<getRandomElement('red', 'green', 'blue')>13. getRandomDate(from?, to?)
lightweightReturns a random date and time between two bounds.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| from | date/time string | No | 2000-01-01T00:00:00Z |
| to | date/time string | No | 2030-12-31T23:59:59Z |
<getRandomDate('2020-01-01', '2020-12-31')>14. getRandomStreet(locale?)
lightweightReturns a random street name with a house number.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| locale | string | No | 'en' |
<getRandomStreet()>15. getRandomCity(locale?)
lightweightReturns a random city name.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| locale | string | No | 'en' |
<getRandomCity()>16. getRandomCountry()
lightweightReturns a random country name.
No parameters.
<getRandomCountry()>17. getRandomAddress(locale?)
lightweightReturns a full composed address string (street, city, and country together).
| Param | Type | Required | Default / notes |
|---|---|---|---|
| locale | string | No | 'en' |
<getRandomAddress()>18. appendBefore(char, value, totalLength)
lightweightPads a value on the left with a repeating character up to a target length — useful for zero-padded IDs and codes.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| char | string | Yes | — |
| value | string | Yes | — |
| totalLength | number | Yes | — |
<appendBefore('0', getVar(idVar), 8)>19. appendAfter(char, value, totalLength)
lightweightPads a value on the right with a repeating character up to a target length.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| char | string | Yes | — |
| value | string | Yes | — |
| totalLength | number | Yes | — |
<appendAfter('x', 'ab', 5)>20. toUpperCase(value)
lightweightConverts a string to uppercase.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| value | string | Yes | — |
<toUpperCase(getVar(name))>21. toLowerCase(value)
lightweightConverts a string to lowercase.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| value | string | Yes | — |
<toLowerCase('HELLO')>22. formatDate(value, pattern)
lightweightFormats a date/time value using a custom pattern (for example YYYY-MM-DD).
| Param | Type | Required | Default / notes |
|---|---|---|---|
| value | date/time string | Yes | — |
| pattern | string | Yes | tokens like YYYY, MM, DD, HH, mm, ss |
<formatDate(getRandomDate(), 'YYYY-MM-DD')>23. formatNumber(value, decimals, decimalSeparator?, thousandsSeparator?)
lightweightFormats a number with a fixed number of decimal places and custom separators.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| value | number | Yes | — |
| decimals | number | Yes | — |
| decimalSeparator | string | No | '.' |
| thousandsSeparator | string | No | '' |
<formatNumber(1234.5, 2, '.', ',')>produces "1,234.50"
24. getParam(name, default?)
lightweightReads a value that was passed in by the caller when requesting generation (a "generation parameter"), letting a single template be customized per-call without editing the template itself.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| name | string | Yes | — |
| default | any | No | fallback value if the parameter was not supplied; if omitted and the parameter is missing, generation fails with an error |
<getParam('customerName', 'Guest')>25. getContext(name)
statefulReads a value that ties the current document to others in the same batch — for example, a parent record's id when generating a batch of related child records. Fails with an error if no such value is available for the current document.
| Param | Type | Required | Default / notes |
|---|---|---|---|
| name | string | Yes | — |
<getContext('orderId')>getContext is grouped in the stateful cost tier for billing purposes, even though it doesn't itself perform an external storage lookup — it's simply classified that way under the platform's internal cost model for relational/batch generation.