MockData CFC

This is a ColdFusion version of the MockData Node.js service.

MockData is a simple service to generate fake JSON data via command line arguments. The idea being that you may be offline, may not have access to an API, or simply need some fake data to test something on your front end.


  • ColdFusion 11+
  • Lucee 4.5+


Leverage CommandBox ant type box install mockdatacfc


You can use this MockData object in several ways:

  1. Put it in your ColdFusion web server and call it directly via CFC method new MockData().mock()) or via web method shown below.
  2. Startup a CommandBox server (box server start) and execute it via port: 3000
  3. Install it as a module in a ColdBox app and hit the service via /mockdataCFC

To specify a port or change the port, just add it an argument:

box server start port=XXXX

To get data from the service, point your XHR at:


Note: MockData uses CORS so if you're running a virtual domain then you will still be able to hit the service.(As long as you have a decent browser.)

Number of objects

There are 2 types of arguments you pass to the object. The first is the number of objects you want returned via the num argument.


By default, MockData will return 10 objects. You can also specify a random number by using the form: rnd:X


This will return a random number of objects from 1 to 10. If you want to specify your own range, just use the form: rnd❌ Y

http://localhost:3000/?num=rnd:5: 10

Type of data

In order to define the type of data returned, you must specify one or more additional query string variables. The form is name=type, where name will be the name used in the result and type is the type of data that we support. Here is a simple example:


This tells the service to return 10 objects with each containing an authorfield that has a type value of name. (More on types in a minute.) The result then would look something like this:

author: "Frank Smith"
author: "Gary Stroz"
author: "Lynn Padgett"

Additional fields than can just be appended to the URL:

http://localhost:3000/?num=3&author=name&gender=oneof:male:  female

Which gives...

author: "Lisa Padgett",
gender: "male"
author: "Roger Clapton",
gender: "male"
author: "Heather Degeneres",
gender: "male"


autoincrement : Returns an incremented index

string: Just returns string (not sure about this one)

name: Generates a random name.

fname: Generates a random first name.

lname: Generates a random last name.

age: Generates a random "adult" age of 18 to 75.

all_age: Generates a random age of 1 to 100.

email: Generates a random email.

ssn: Generates a random Social Security number.

tel: Generates a random (American) telephone number.

num: By default, a number from 1 to 10. You can also use the form num:X for a random number between 1 and X. Or num❌ Y for a random number between X and Y.

oneof: Requires you to pass N values after it delimited by a colon. Example: "oneof:male: female". Will return a random value from that list.

lorem: Returns lorem ipsum text. If used as lorem:N, returns N paragraphs. If used as lorem❌ Y, returns a random number of paragraphs between X and Y.

baconlorem: Returns bacon lorem ipsum text. If used as baconlorem:N, returns N paragraphs. If used as baconlorem❌ Y, returns a random number of paragraphs between X and Y.

uuid: Generates a random UUID

date: Generates a random date

datetime: Generates a random date and time value

sentence: Generates a sentences. If used as sentence:N, returns N sentences. If used as sentence❌ Y, returns a random number of sentences beetween X and Y.

words: Generates a single word. If used as word:N, returns N words. If used as words❌ Y, returns a random number of words beetween X and Y.



  • Added auto-incrementing ID's FOR REAL this time


  • Added auto-incrementing ID's
  • Update on build control
  • Syntax Ortus Updates, addition of private methods
  • allow for use of rand or rnd for num generators
  • Add CORS support for ColdBox REST Module
  • Bug on isDefault() always returning true.
  • Added tests and automation


  • Made it a module as well for ColdBox apps.


  • Added support for words, sentences, uuid, bacon lorem, date and datetime
  • Added CommandBox Support
  • Added Documentation
  • Added ability to execute as a CFC instead of only via web service


Original by Ray Camden


$ box install mockdatacfc
No collaborators yet.
  • Oct 19 2016 08:52 AM
  • Apr 25 2018 04:57 PM
  • 534
  • 0
  • 174