Data Generation using Mockaroo

At a recent client engagement, my colleague had to create some location data for testing one of the client application. The data creation involved multiple steps like downloading some data from the net, removing some columns, transforming it as per needs using Python code. The process was a bit time-consuming. Recently when I was searching for some tools for data gathering I chanced upon a tool called Mockaroo. Mockaroo is an excellent tool for generating realistic test data. I found it really helpful and it fit my needs very well. This post is about how I could use different features of Mockaroo which I felt would be very helpful for anyone testing data intensive applications.

Data Requirements

Our requirement was a bit more complex than just using random names or address. We had fields like Longitude, Latitude, Address, Area calculation mode, Radius, Travel mode, Travel type. Longitude and Latitude attributes are based on the location details. The Address field is a combination of Street, Province, and Postal Code. Area calculation mode has two dependent parameters ‘radius’ and ‘travel-time’. If area calculation mode is ‘radius’ then we had to set the ‘radius’ parameter to be a radius in miles. If the area calculation mode was set to ‘travel-time’, we had to set ‘travel mode’ to one of “Bike”, “Walk”, or “Drive” and then we had to set the value of ‘travel-time’ to a number of minutes around the location. The fields ‘travel mode’ and ‘radius’ correspond with the field ‘area calculation mode’. As you can guess, a lot of manual effort was needed for populating this kind of test data.

Using Mockaroo to generate the data

Mockaroo is a brilliant online tool that lets you solve the data generation problems in a few clicks. It provides a GUI to build some data that suits your needs and lets you generate up to 1,000 rows of realistic test data in CSV, JSON, SQL, and Excel formats. It generates data from a saved schema which can be helpful for automated testing.

The tool has columns for data field names, their data types and blank options which you can alter to adjust the data order and specifications. You simply enter a field name and select a data type. You can move fields up using the handle bars on the left, or delete fields using the cross on the right. The column named ‘Field Name’ accepts simple text input, ‘Type’ accepts data type and ‘Options’ accepts numerical input. You can add more fields by clicking on the “Add another field” button.

Mockaroo Schema UI

Mockaroo supports around 74 different types, each of these data type provides a range of appropriate sample data that is used to populate the field. You can view the list of 74 types on the API docs page as shown below. You can also customize the data types according to your data needs.

Mockaroo API doc page

Different operations using Mockaroo Data Types

Mockaroo has a lot of useful features. In this section, I’ll talk about the ones I found most useful features like Formulas, Functions, Custom List which we have applied for data transformations specific for our requirement. Here is link to location_details Schema which we created for our data creation (See Mockaroo- Location_details Schema image)

Longitude and Latitude Data types

Generating realistic data for Longitude and Latitude fields in our data set was a time-consuming process. Mockaroo made it simple. Mockaroo supports a data type called Longitude and Latitude which allows us to generate data for longitude and latitude values for the given location details. This helped us to create this data quickly and made our job simple.

Custom List

Custom List is another data type which is appropriate for populating default values in the fields. It picks items randomly or sequentially from a custom list of values specified. For our requirement, we choose Custom List values for the field ‘Area calculation mode’ to generate random data values ‘radius’ or ‘travel-mode’ for each row.


Formula is a powerful feature of Mockaroo to generate any kind of data we want. You can use formulas to create your own data types in Mockaroo. It helps to reference existing fields and generate data based on the custom code. Using formulas you can do things like writing different functions for date diff, concatenate strings, mathematical calculations, conditional logic etc…, Any kind of data transformation is made simple using these formulas.

Concat Function

The Address field in our requirement is a combination of Street, Province, and Postal code. We used concat function to concatenate all these strings. The Mockaroo API doc has all the syntax for different functions. Please see the above image for the concat function. Similarly, you can use different logical operators, functions, Regular Expressions to do data transformations.

Conditional IF Statements

If you want a value based of some incoming value from another field you can utilize conditional IF statements. In our case, for the field radius, we want to generate some values from 1 to 20 based on another field called Area calculation mode. So we could achieve this by using IF conditional statements(See below image for formula).

Mockaroo- Location_details Schema

If you notice in the location_details schema, you’ll also see that there are a couple of extra variables which we don’t need in our dataset. These variables are commonly found when you create data using formulas. Mockaroo allows us to hide the fields which we don’t need in our desired data set. You can just type ‘__'(two underscore) characters in front of the field you want to hide, it will be automatically hidden. This is useful when creating intermediate fields for use in formulas and templates. For example, in our case the fields like ‘___address_type’,’__state_type’,’__province’, ‘__postal_code’ were created to refer in the concat function to generate data for Address field.

Apart from these feature Mockaroo provides with some additional features which are useful like

  • Specify number of rows to be generated.
  • The ‘Download Data’ button to download the data.
  • You can preview what data will be downloaded by clicking on the “Preview” button.
  • You can save the setting to your profile through the “Clone This Schema” button
  • Import fields from csv or sql

Once you are done with the field manipulations, you can save this schema and once you save this schema you’ll be given a Share Link to the schema.

Mockaroo Rest API

Mockaroo provides a REST API, which lets you download randomly generated data into your projects in real-time with unlimited calls. Using REST API you can easily integrate into test automation workflow for repeatable test data generation. You can download based on a saved schema or fields you define at runtime. Anything you can generate via the website can also be generated via the REST API.

Mockaroo Rest API URL

The API contains a single method:


This method will return CSV or JSON formats depending on the file type part of the URL. You can find more details on Mockaroo REST API here

I found Mockaroo is a really great, free product and is perfect if you need to generate test data quickly.


1. Creating Test Data with Mockaroo

2. How to generate random, realistic & reliable data for your application?

3. Generate Test Data Quickly In Two Easy Steps

A weekly newsletter for testers

View a sample

Indira Nellutla
I am an engineer with about 10 years of experience in software development and testing. Prior to joining Qxf2, I worked with reputed companies like Dell and Infosys. They helped me gain good experience in the manufacturing and healthcare domains. My QA career started at Dell. I got exposure to various testing tools, processes and methodologies, got an opportunity to work on various platforms like JMS Hermes, SOAP UI, data integration, queues, etc. I chose Qxf2 because it allowed remote working. My interests are vegetable gardening using organic methods, listening to music and reading books.

© 2013-2017, Indira Nellutla. All rights reserved.

Be First to Comment

Leave a Reply

Your email address will not be published.