JsonFabrica

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.

FunctionSignatureCost tier
createSeqcreateSeq(name, type?, start?, step?)stateful
getSeqgetSeq(name)stateful
getVargetVar(name)lightweight
setVarsetVar(name, value)lightweight
getRandomNamegetRandomName(locale?)lightweight
getRandomSurnamegetRandomSurname(locale?)lightweight
getRandomFullNamegetRandomFullName(locale?)lightweight
getRandomEmailgetRandomEmail(domain?)lightweight
getRandomNumbergetRandomNumber(min?, max?, decimals?)lightweight
getRandomBooleangetRandomBoolean(trueProbability?)lightweight
getRandomTextWithSpacesgetRandomTextWithSpaces(minLen, maxLen)lightweight
getRandomElementgetRandomElement(...values)lightweight
getRandomDategetRandomDate(from?, to?)lightweight
getRandomStreetgetRandomStreet(locale?)lightweight
getRandomCitygetRandomCity(locale?)lightweight
getRandomCountrygetRandomCountry()lightweight
getRandomAddressgetRandomAddress(locale?)lightweight
appendBeforeappendBefore(char, value, totalLength)lightweight
appendAfterappendAfter(char, value, totalLength)lightweight
toUpperCasetoUpperCase(value)lightweight
toLowerCasetoLowerCase(value)lightweight
formatDateformatDate(value, pattern)lightweight
formatNumberformatNumber(value, decimals, decimalSeparator?, thousandsSeparator?)lightweight
getParamgetParam(name, default?)lightweight
getContextgetContext(name)stateful

1. createSeq(name, type?, start?, step?)

stateful

Declares 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.

ParamTypeRequiredDefault / notes
namestringYes
type'number' | 'string' | 'uuid'No'number'
startnumberNo0
stepnumberNo1
Example
<createSeq('orderNo', 'number', 1000, 1)>

2. getSeq(name)

stateful

Returns the next value from a sequence you've already declared with createSeq, advancing it each time it's called.

ParamTypeRequiredDefault / notes
namestringYes
Example
<getSeq('orderNo')>

3. getVar(name)

lightweight

Reads back a value previously stored under a variable name — either earlier in the same template, or a shared variable available across your account.

ParamTypeRequiredDefault / notes
namestringYes
Example
<getVar('customerName')>

4. setVar(name, value)

lightweight

Stores a value under a variable name so it can be read back later in the same template with getVar.

ParamTypeRequiredDefault / notes
namestringYes
valueanyYes
Example
<setVar('discount', 10)>

5. getRandomName(locale?)

lightweight

Returns a random first name.

ParamTypeRequiredDefault / notes
localestringNo'en'
Example
<getRandomName('en')>

6. getRandomSurname(locale?)

lightweight

Returns a random surname.

ParamTypeRequiredDefault / notes
localestringNo'en'
Example
<getRandomSurname()>

7. getRandomFullName(locale?)

lightweight

Returns a random full name (first name and surname together).

ParamTypeRequiredDefault / notes
localestringNo'en'
Example
<getRandomFullName('en')>

8. getRandomEmail(domain?)

lightweight

Returns a synthetic, realistic-looking email address built from random names.

ParamTypeRequiredDefault / notes
domainstringNorandom from a built-in list
Example
<getRandomEmail('example.com')>

9. getRandomNumber(min?, max?, decimals?)

lightweight

Returns a random number within a range — an integer by default, or a decimal number if requested.

ParamTypeRequiredDefault / notes
minnumberNo0
maxnumberNo100
decimalsnumberNo0
Example
<getRandomNumber(1, 5, 0)>

10. getRandomBoolean(trueProbability?)

lightweight

Returns a random true/false value.

ParamTypeRequiredDefault / notes
trueProbabilitynumber (0–1)No0.5
Example
<getRandomBoolean(0.7)>

11. getRandomTextWithSpaces(minLen, maxLen)

lightweight

Generates random placeholder-style text within a given length range.

ParamTypeRequiredDefault / notes
minLennumberYes
maxLennumberYesmust be ≥ minLen
Example
<getRandomTextWithSpaces(10, 20)>

12. getRandomElement(...values)

lightweight

Picks 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.

ParamTypeRequiredDefault / notes
valuesany[] | variable nameYespool of values, or a single variable name referencing an array
Example
<getRandomElement('red', 'green', 'blue')>

13. getRandomDate(from?, to?)

lightweight

Returns a random date and time between two bounds.

ParamTypeRequiredDefault / notes
fromdate/time stringNo2000-01-01T00:00:00Z
todate/time stringNo2030-12-31T23:59:59Z
Example
<getRandomDate('2020-01-01', '2020-12-31')>

14. getRandomStreet(locale?)

lightweight

Returns a random street name with a house number.

ParamTypeRequiredDefault / notes
localestringNo'en'
Example
<getRandomStreet()>

15. getRandomCity(locale?)

lightweight

Returns a random city name.

ParamTypeRequiredDefault / notes
localestringNo'en'
Example
<getRandomCity()>

16. getRandomCountry()

lightweight

Returns a random country name.

No parameters.

Example
<getRandomCountry()>

17. getRandomAddress(locale?)

lightweight

Returns a full composed address string (street, city, and country together).

ParamTypeRequiredDefault / notes
localestringNo'en'
Example
<getRandomAddress()>

18. appendBefore(char, value, totalLength)

lightweight

Pads a value on the left with a repeating character up to a target length — useful for zero-padded IDs and codes.

ParamTypeRequiredDefault / notes
charstringYes
valuestringYes
totalLengthnumberYes
Example
<appendBefore('0', getVar(idVar), 8)>

19. appendAfter(char, value, totalLength)

lightweight

Pads a value on the right with a repeating character up to a target length.

ParamTypeRequiredDefault / notes
charstringYes
valuestringYes
totalLengthnumberYes
Example
<appendAfter('x', 'ab', 5)>

20. toUpperCase(value)

lightweight

Converts a string to uppercase.

ParamTypeRequiredDefault / notes
valuestringYes
Example
<toUpperCase(getVar(name))>

21. toLowerCase(value)

lightweight

Converts a string to lowercase.

ParamTypeRequiredDefault / notes
valuestringYes
Example
<toLowerCase('HELLO')>

22. formatDate(value, pattern)

lightweight

Formats a date/time value using a custom pattern (for example YYYY-MM-DD).

ParamTypeRequiredDefault / notes
valuedate/time stringYes
patternstringYestokens like YYYY, MM, DD, HH, mm, ss
Example
<formatDate(getRandomDate(), 'YYYY-MM-DD')>

23. formatNumber(value, decimals, decimalSeparator?, thousandsSeparator?)

lightweight

Formats a number with a fixed number of decimal places and custom separators.

ParamTypeRequiredDefault / notes
valuenumberYes
decimalsnumberYes
decimalSeparatorstringNo'.'
thousandsSeparatorstringNo''
Example
<formatNumber(1234.5, 2, '.', ',')>

produces "1,234.50"

24. getParam(name, default?)

lightweight

Reads 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.

ParamTypeRequiredDefault / notes
namestringYes
defaultanyNofallback value if the parameter was not supplied; if omitted and the parameter is missing, generation fails with an error
Example
<getParam('customerName', 'Guest')>

25. getContext(name)

stateful

Reads 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.

ParamTypeRequiredDefault / notes
namestringYes
Example
<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.