Matt Sweetman

Latest articles

New version of dummy-json

I'm proud to announce the latest version of dummy-json, my mock JSON generator for Node. It's now officially at version 1.0.0!

This is a significant update with lots of new features. You can now generate all kinds of data from names and addresses to GUIDs and colors. It's also possible to set a random seed, allowing the same results to be generated every time. If you're using dummy-json in your own projects this means you can now write tests against the output.

Under the hood there's been a major refactor, with the entire core being rewritten to take advantage of the latest version of Handlebars. Implementing the random seed also required changes to the underlying architecture, but the final result is a more modular and extensible version of dummy-json.

New helpers

There's over 15 new helpers, many of which have been suggested by people who have used the library. I've also updated some of the existing helpers to make them more powerful. Below is a quick glance at a few of the new additions, and you can take a look at the readme for a complete list.


{{number}} has been separated into {{interger}} and {{float}} and now supports an optional formatting string. This allows you to generate currency-like values.

{{int 0 100}} // 43
{{float 10000 50000 '0,0.00'}} // 23,462.88

Date and time

Both these helpers now support a formatting string:

{{date '2010' '2015' 'DD/MM/YYYY'}} // 16/06/2012
{{time '09:00' '17:30' 'h:mm a'}} // 2:08 pm


There are a collection of over 100 street names and cities allowing you to generate full addresses. You can provide your own address data if you wish to use different street or city names.

{{int 100 300}} {{street}}
{{city}} {{postcode}}

// 221 Baker Street
// London NW1 6XE
// England

Phone numbers

The new phone number helper allows you to provide a mask to generate numbers in any format:

{{phone}} // 445-295-1044
{{phone "+64 (x) xxx xxxx"}} // +64 (5) 883 4711

Lorem ipsum

This generates a specific number of words of lorem ipsum. It automatically inserts punctuation to create sentences.

{{lorem 6}} //  Orci nisi laoreet maximus, dictum om.

Random seed

The original dummy-json generated random values every time it was run. It turned out there were situations where it was preferable to repeat the results. One of these situations was my ability to write tests against the core dummy-json code. I couldn't do it if the results were different every time. So I replaced the default Math.random generator with a third party library that supports seeds.

By default dummy-json is still random, but now you can set an optional seed:

// The seed can be any arbitrary string value
var result = dummyjson.parse(string, {seed: 'abc123'});

Using the same seed every time will generate the same results. Omitting the seed will generate different results.


There are a few breaking changes to the API and built-in helpers which might require you to update your code. For more information see the upgrading section of the readme.

If you find any bugs or have any ideas for additional features then let me know!