3.1.1 • Public • Published


Generate a tournament bracket.

NPM Build Status Greenkeeper badge

What is this?

bracket-generator, well, it generates brackets! (Check out bracket-data for more info about brackets and their data.)

More specifically, this module generates a string representation of a bracket. That string can then be used with a whole bunch of others modules to validate it, update it, or score it.

This module isn't that useful for selecting brackets (unless you wanted to stage an epic robot bracket challenge, wait, that'd be awesome) but it is useful for testing other bracket modules and creating random (or not-so-random) brackets.

API / Usage

Make a new bracket-generator object with an options object (the year and sport options are required and passed directly to bracket-data):

var BracketGenerator = require('bracket-generator');
var generator = new BracketGenerator({
   year: '2013',
   sport: 'ncaam',
   winners: 'random'


  • sport: The sport you are generating. See bracket-data for more info.
  • year: The year you are generating. See bracket-data for more info.
  • winners: (String, default: 'random') How the winners of the bracket should be selected. See below for the explantion of each option:


The winners option can be a few things:

  • random: it will generate a random bracket! (it probably won't win any office pools)
  • higher: all higher seeds will win. If two seeds are the same, the seed on the bottom of the matchup will win (definitely wont win any office pools)
  • lower: all lower seeds will win. If two seeds are the same, the seed on the top of the matchup will win
  • A binary string (10101110...). The string you pass in should have a length matching the number of games in the bracket. This will generate a bracket with each matchup corresponding to a single character in the string. If the character is 0 the lower seed will win. If the character is 1 the higher seed will win. This is useful because it allows you to create every possible bracket! See the tests for how I accomplished that.


  • generate(winners): Generate the bracket. The param winners is optional here. If you pass it in, it will reset the generator first and then generate a bracket using the winners option you passed in, otherwise it will use the option it was instantiated with. It will a bracket string.



Package Sidebar


npm i bracket-generator

Weekly Downloads






Unpacked Size

19.7 kB

Total Files


Last publish


  • lukekarrys