Overview
Mockend random generator is extremely flexible. It provides all the building blocks to generate any value.
See Custom Data for ways to provide your own data.
Meta
_.items
Use this field to control how many items you want Mockend to create (default/max: 100
). For example, to create 10 posts:
{
"Post": {
"_": { "items": 10 }
}
}
Primitives
string|string[]
Generates a random string.
{ "title": { "string": {} }
Pick a random string.
{
"category": {
"string": ["One", "Two"]
}
}
int|int[]
Generates a random integer between min
and max
.
{ "likes": { "int": { "min": 0, "max": 1000000 } } }
Pick a random integer in array.
{
"code": {
"int": [100, 200, 300]
}
}
boolean
Generates a random boolean.
{ "isPublished": { "boolean": {} } }
Dates
dateTime
Generates a random RFC3339 (opens in a new tab) DateTime between min
and max
.
{
"createdAt: {
"dateTime": {
"min": "2010-01-01T00:00:00Z",
"max": "2020-12-31T23:59:59Z"
}
}
}
Lorem ipsum
loremWord
Generates a random word.
{
"tag": {
"loremWord": {}
}
}
loremWords
Generates random words between minLength
and maxLength
.
{
"title": {
"loremWords": { "minLength": 5, "maxLength": 20 }
}
}
loremSentences
Generates random sentences between minLength
and maxLength
.
{
"longDescription": {
"loremSentences": { "minLength": 100, "maxLength": 200 }
}
}
loremParagraphs
Generates random paragraphs between minLength
and maxLength
.
{
"text": {
"loremParagraphs": { "minLength": 200, "maxLength": 500 }
}
}
Regexp
Generates a random string based on regular expression.
{ "name": { "regexp": "[A-Z][a-z]{5,10}" } }
Examples
regexp
generator is a powerful way to create any string. Here are some examples to get you started. Feel free to adapt them to suit your needs.
Pictures
{
"avatar": {
"regexp": "https://i\\.pravatar\\.cc/150\\?u=[0-9]{5}"
},
"photo": {
"regexp": "https://picsum\\.photos/seed/[0-9]{5}/1920/1080"
}
}
Generates URLs to online services with a random seed ([0-9]{5} = 5 random numbers
).
Names
{ "firstName": { "regexp": "[A-Z][a-z]{5,10}" } }
Generates a random string starting with an uppercase letter and between 5 to 10 lowercase letters.
Emails
{ "email": { "regexp": "[a-z]{5,10}@[a-z]{5}\\.[a-z]{2,3}" } }
Generates an email containing @
and with a domain of 2 or 3 letters.
Hex colors
{ "color": { "regexp": "#[0-9A-F]{6}" } }
Generates an hex color.