Chance - Utility library to generate anything random

npm install chance
84 downloads in the last day
468 downloads in the last week
2 600 downloads in the last month


Chance Logo

Build Status

Chance - Random generator helper for JavaScript


Many more details on but this single library can generate random numbers, characters, strings, names, addresses, dice, and pretty much anything else.

It includes the basic building blocks for all these items and is built on top of a Mersenne Twister so it can generate these things with repeatability, if desired.



Chance instantiates itself onto the window. This means that in the simplest case you can just include the script tag then use an instance of Chance immediately.

<script src="chance.js"></script>

More info


It can also be used with Bower

bower install chance

then in the HTML of your app:

<!-- Load Chance -->
<script type="text/javascript" src="app/bower_components/chance/chance.min.js"></script>
    // Use Chance immediately!


It can also be used with Component

component install victorquinn/chancejs

then in the HTML of your app:

<!-- Load Chance -->
<script type="text/javascript" src="components/victorquinn-chancejs/chance.js"></script>
    // Use Chance immediately!


And it can be used in Node.js.

var Chance = require('chance'),
    chance = new Chance();

// Get a random zip code;


Chance also includes an AMD define so it can be used with RequireJS.

require(['Chance'], function(Chance) {
    // Instantiate
    var chance = new Chance();

    // Then just use it:
    var my_random_integer = chance.integer();

## Author
### Victor Quinn

Please feel free to reach out to me if you have any questions or suggestions.

### Contributors


project : chancejs repo age : 9 months active : 48 days commits : 251 files : 25 authors : 197 Victor Quinn 78.5% 11 Tim Petricola 4.4% 11 davmillar 4.4% 5 Matt Klaber 2.0% 5 Michael Cordingley 2.0% 4 Kevin Garnett 1.6% 3 qjcg 1.2% 2 Andreas Koeberle 0.8% 2 dhilipsiva 0.8% 2 path411 0.8% 1 Ng, Patrick 0.4% 1 Bitdeli Chef 0.4% 1 Dominic Barnes 0.4% 1 Doug Lawrence 0.4% 1 Johannes Stein 0.4% 1 Adam Krebs 0.4% 1 Richard Anaya 0.4% 1 Ryan Tenney 0.4% 1 leesei 0.4% ```

This project is licensed under the MIT License so feel free to hack away :)

Bitdeli Badge

npm loves you