Plugins provide the following features:
Brauhaus.js was developed with and for Malt.io, a community website for homebrewers to create recipes and share their love of homebrewing beer.
There are two ways to use Brauhaus.js - either in a web browser (client-side) or on e.g. Node.js (server-side).
To use Brauhaus.js in a web browser, simply download the following file and include it as you would any other script:
<!-- Plugins go here... -->
For Node.js, you can easily install Brauhaus.js and plugins using
npm install brauhaus
Here is an example of how to use the library from CoffeeScript:
# The following line is NOT required for web browser useBrauhaus = require 'brauhaus'# Import plugins here, e.g.require 'brauhaus-beerxml'# Create a reciper =name: 'My test brew'description: 'A new test beer using Brauhaus.js!'batchSize: 20.0boilSize: 10.0# Add ingredientsradd 'fermentable'name: 'Extra pale malt'color: 2.5weight: 4.2yield: 78.0radd 'hop'name: 'Cascade hops'weight: 0.028aa: 5.0use: 'boil'form: 'pellet'radd 'yeast'name: 'Wyeast 3724 - Belgian Saison'type: 'ale'form: 'liquid'attenuation: 80# Set up a simple infusion mashr.mash =name: 'My mash'ph: 5.4rmashaddStepname: 'Saccharification'type: 'Infusion'time: 60temp: 68waterRatio: 2.75# Calculate valuesrcalculate# Print out calculated valuesconsolelog "Original Gravity: "consolelog "Final Gravity: "consolelog "Color: ° SRM ()"consolelog "IBU: "consolelog "Alcohol: % by volume"consolelog "Calories: kcal"
// The following line is NOT required for web browser usevar Brauhaus = require'brauhaus';// Import plugins here, e.g.require'brauhaus-beerxml';// Create a recipevar r =name: 'My test brew'description: 'A new test beer using Brauhaus.js!'batchSize: 20.0boilSize: 10.0;// Add ingredientsradd'fermentable'name: 'Extra pale malt'color: 2.5weight: 4.2yield: 78.0;radd'hop'name: 'Cascade hops'weight: 0.028aa: 5.0use: 'boil'form: 'pellet';radd'yeast'name: 'Wyeast 3724 - Belgian Saison'type: 'ale'form: 'liquid'attenuation: 80;// Set up a simple infusion mashrmash =name: 'My mash'ph: 5.4;rmashaddStepname: 'Saccharification'type: 'Infusion'time: 60temp: 68waterRatio: 2.75;// Calculate valuesrcalculate;// Print out calculated valuesconsole.log'Original Gravity: ' + rogtoFixed3;console.log'Final Gravity: ' + rfgtoFixed3;console.log'Color: ' + rcolortoFixed1 + '° SRM (' + rcolorName + ')';console.log'IBU: ' + ributoFixed1;console.log'Alcohol: ' + rabvtoFixed1 + '% by volume';console.log'Calories: ' + Mathroundrcalories + ' kcal';
The following values may be configured and will apply to all recipes, ingredients, etc.
|BURNER_ENERGY||number||9000||Heat source output in kilojoules per hour|
|COLOR_NAMES||array||...||An array of color names for °SRM color ranges|
|MASH_HEAT_LOSS||number||5||Degrees C lost per hour during mash|
|RELATIVE_SUGAR_DENSITY||object||...||Keys are types of sugar, values are relative density|
|ROOM_TEMP||number||23||Room temperature in degrees C|
The following functions are available to parse and display durations of time:
Parse a string value into a duration in minutes. Supports many optional suffixes like
>>> BrauhausparseDuration'2 days'2880>>> BrauhausparseDuration'1hr 3 minutes'63>>> BrauhausparseDuration'12'12
Generates a human-friendly display string from a number of minutes. Approximate, if set, determines the maximum number of units to return, rounding the last unit. For example, a setting of
2 would return days and hours; or hours and minutes; but never days, hours, and minutes.
>>> BrauhausdisplayDuration65'1 hour 5 minutes'>>> BrauhausdisplayDuration2833'1 day 23 hours 13 minutes'>>> BrauhausdisplayDuration2833 2'1 day 23 hours'>>> BrauhausdisplayDuration2833 1'2 days'
The following functions are available to convert between various forms:
Convert kilograms to pounds.
Convert pounds to kilograms.
Convert kilograms to pounds and ounces.
>>> BrauhauskgToLbOz2.5lb: 5oz: 8.184799999999996
Convert pounds and ounces to kilograms.
>>> BrauhauslbOzToKg5 8.1847999999999962.5
Convert liters to gallons.
Convert gallons to liters.
Convert l/kg to qt/lb.
Convert qt/lb to l/kg.
Convert a temperature from celcius to fahrenheit.
Convert a temperature from fahrenheit to celcius.
Convert a yield percentage to parts per gallon.
Convert parts per gallon to a yield percentage.
Colors can be easily converted into various useful formats for the screen and web.
Convert a color in °SRM to °EBC.
Convert a color in °EBC to °SRM.
>>> BrauhausebcToSrm 2010.16
Convert a color in °SRM to °Lovibond.
Convert a color in °Lovibond to °SRM.
Convert a color in °SRM to a RGB triplet.
>>> BrauhaussrmToRgb8208 88 13
Convert a color in °SRM to a form usable in a CSS color string.
>>> BrauhaussrmToCss8'rgb(208, 88, 14)'
Convert a color in °SRM to a human-readable color.
>>> BrauhaussrmToName8'deep gold'
Get the time in minutes to heat a volume of water in liters by a number of degrees C given the heat source defined by
>>> BrauhaustimeToHeat10.0 80.022.34666666666667
The following list of objects are available within Brauhaus:
A Brauhaus object can be easily serialized and deserialized from a JSON format. Deserialization can be from a JSON string or an object (i.e. the value given by
JSON.parse(...)). For example, to serialize and deserialize a recipe object:
var r serialized;// Serializer = ;serialized = JSONstringifyr;// Deserialize from JSON stringserialized = '...';r = serialized;// Deserialize from parsed objectserialized = JSONparse'...';r = serialized;
Note: there is also a BeerXML plugin available which can serialize / deserialize BeerXML 1.0.
A fermentable is some kind of a sugar that yeast can metabolize into CO2 and alcohol. Fermentables can be malts, malt extracts, honey, sugar, etc. Each fermentable can have the following properties:
|color||number||2.0||Color in °SRM|
|name||string||New fermentable||Name of the fermentable|
|weight||number||1.0||Weight in kilograms|
Get the addition type of fermentable, one of
Get the color triplet for this fermentable. Shortcut for
>>> fcolorRgb233 157 63
Get the CSS-friendly color string for this fermentable. Shortcut for
>>> fcolorCss'rgb(233, 157, 63)'
Get the human-readable name for the color of this fermentable. Shortcut for
>>> fcolorName'deep gold'
Get the gravity units of this fermentable for a number of liters, based on the weight and yield. These units make the original gravity when divided by 1000 and added to one.
Get the gravity in degrees plato for this fermentable for a number of liters, based on the weight and yield.
Get the parts per gallon from the yield percentage.
Guess the price in USD per kilogram of this fermentable, based on the name. Prices are an approximation based on multiple online homebrew supply store prices. You should use
toFixed(2) to display these.
Get the type of fermentable, either
A shortcut for
Brauhaus.kgToLb(f.weight) to get the weight in pounds.
A shortcut for
Brauhaus.kgToLbOz(f.weight) to get the weight in pounds and ounces.
>>> fweightLbOzlb: 2oz: 4.3
A spice is some kind of substance added to flavor or protect a brew. Spices can be hops, coriander, orange peel, cinnamon, whirlfloc, Irish moss, rose hips, etc. Each spice can have the following properties:
|aa||number||0.0||Alpha-acid percentage (0 - 100)|
|form||string||pellet||Form, like pellet, whole, ground, crushed, etc|
|name||string||New spice||Name of the spice|
|time||number||60||Time in minutes to add the spice|
|use||string||boil||When to use the spice (mash, boil, primary, etc)|
|weight||number||1.0||Weight in kilograms|
Calculate the IBU of a spice for the given method, early OG, and batch size in liters. Available methods are
'rager'. The early OG is usually calculated as the sum of gravity values for all non-late fermentables.
>>> sbitterness'tinseth' 1.045 1912.4
True if the spice is added after the boil, otherwise false. This is useful for determining if dry hopping is taking place.
Guess the price in USD per kilogram of this spice, based on the name. Prices are an approximation based on multiple online homebrew supply store prices. You should use
toFixed(2) to display these.
Get the utilization factor based on the form of a spice. For example, pellets are easier to utilize than whole leaf hops.
A shortcut for
Brauhaus.kgToLb(s.weight) to get the weight in pounds.
A shortcut for
Brauhaus.kgToLbOz(s.weight) to get the weight in pounds and ounces.
>>> sweightLbOzlb: 0oz: 1
Yeast are the biological workhorse that transform sugars into alcohol. Yeast can be professional strains like Wyeast 3068, harvested from bottles, harvested from the air, or other bugs like bacteria that produce acid.
|attenuation||number||75.0||Percentage of sugars the yeast can convert|
|form||string||liquid||Liquid or dry|
|name||string||New yeast||Name of the yeast|
|type||string||ale||Ale, lager, or other|
Guess the price in USD per packet of this yeast, based on the name. Prices are an approximation based on multiple online homebrew supply store prices. You should use
toFixed(2) to display these.
A single step in a multi-step mash, such as infusing water, changing the temperature, or decocting mash to boil.
|endTemp||number||unset||Temperature in degrees C after this step|
|name||string||Saccharification||A name to give this step|
|rampTime||number||unset||Time in minutes to ramp to the given temperature|
|temp||number||68||Temperature in degrees C to hold the mash|
|time||number||60||Duration of this step in minutes|
|type||string||Infusion||Type of mash step:
|waterRatio||number||3.0||Ratio in liters per kg of water to infuse or decoct|
An array of available mash step types:
Decoction. They can generally be broken down as follows:
Infusion: adding hot water to the mash to raise its overall temperature
Temperature: usually adding heat via some source, like a stovetop or gas burner
Decoction: removing and boiling some of the mash, then adding it back to raise the overall temperature
An automatically generated description of the step. If the first argument is
true, then use SI units (liters, kilograms, celcius). If it is
false, then use quarts, pounds and fahrenheit. If a second argument is passed, then it is used as the total grain weight of the recipe to determine the exact amount of water or mash to add/remove.
>>> mashStepdescription'Infuse 3.0l per kg of grain for 60 minutes at 68C'>>> mashStepdescriptionfalse'Infuse 1.44qt per lb of grain for 60 minutes at 154.4F'>>> mashStepdescriptiontrue 3.3'Infuse 10.0l for 60 minutes at 68C'>>> mashStepdescriptionfalse 3.3'Infuse 10.57qt for 60 minutes at 154.4F'
Get the step end temperature in degrees F. Shortcut for
Get the step temperature in degrees F. Shortcut for
Get the water ratio in quarts per pound of grain. Shortcut for
A recipe mash description for all-grain or partial-mash recipes. The mash includes information like a name, notes for the brewer, grain temperature, PH, etc.
|grainTemp||number||23||Grain temperature in degrees C|
|name||string||unset||Name of the mash, e.g.
|notes||string||unset||Notes for the brewer|
|ph||number||unset||Target PH of the mash|
|spargeTemp||number||76||Sparge temperature in degrees C|
|steps||array||||A list of
Add a new mash step with the passed options.
>>> mashprototypeaddStepname: 'Test step'type: 'Infusion'waterRatio: 3.0temp: 68time: 60
Get the grain temperature in degrees F. Shortcut for
Get the sparge temperature in degrees F. Shortcut for
A beer recipe, containing ingredients like fermentables, spices, and yeast. Calculations can be made for bitterness, alcohol content, color, and more. Many values are unset by default and will be calculated when the
Recipe.prototype.calculate() method is called. The
boilEndTime are unset until the
Recipe.prototype.timeline() method is called.
|abv||number||unset||Alcohol percentage by volume|
|abw||number||unset||Alcohol percentage by weight|
|agingDays||number||14.0||Number of days to age keg/bottles|
|agingTemp||number||20.0||Temperature during aging in °C|
|author||string||Anonymous Brewer||Recipe author|
|batchSize||number||20.0||Total size of batch in liters|
|boilSize||number||10.0||Size of wort that will be boiled in liters|
|boilStartTime||number||unset||Time in minutes when the boil starts|
|boilEndTime||number||unset||Time in minutes when the boil ends|
|bottlingPressure||number||0.0||Bottle pressure in volumes of CO2|
|bottlingTemp||number||0.0||Bottling temperature in °C|
|brewDayDuration||number||unset||Duration in minutes for the brew day|
|buToGu||number||unset||Bitterness units to gravity units ratio|
|bv||number||unset||Balance value (bitterness / sweetness ratio)|
|calories||number||unset||Calories per serving (kcal)|
|color||number||unset||Color in °SRM|
|description||string||Recipe description||Recipe description text|
|fg||number||unset||Final gravity (e.g. 1.012)|
|fgPlato||number||unset||Final gravity in °Plato|
|ibu||number||unset||Bitterness in IBU|
|ibuMethod||string||tinseth||IBU calculation method,
|mashEfficiency||number||75.0||Efficiency percentage for the mash|
|name||number||New recipe||Recipe name text|
|og||number||unset||Original gravity (e.g. 1.048)|
|ogPlato||number||unset||Original gravity in °Plato|
|price||number||unset||Approximate price in USD|
|primaryDays||number||14.0||Number of days in primary fermenter|
|primaryTemp||number||20.0||Temperature of primary fermenter in °C|
|primingCornSugar||number||unset||Kg of corn sugar to prime|
|primingDme||number||unset||Kg of dry malt extract to prime|
|primingHoney||number||unset||Kg of honey to prime|
|primingSugar||number||unset||Kg of (table) sugar to prime|
|realExtract||number||unset||Real extract of the recipe|
|secondaryDays||number||0.0||Number of days in secondary fermenter|
|secondaryTemp||number||0.0||Temperature of secondary fermenter in °C|
|servingSize||number||0.355||Serving size in liters|
|steepTime||number||20||Time in minutes to steep ingredients|
|steepEfficiency||number||50.0||Efficiency percentage for steeping|
|steepTime||number||20.0||Time to steep in minutes|
|style||object||null||Recipe style (see
|tertiaryDays||number||0.0||Number of days in tertiary fermenter|
|tertiaryTemp||number||0.0||Temperature of tertiary fermenter in °C|
|timelineMap||object||null||Map used to generate a brew timeline|
Add a new ingredient to the recipe.
type can be one of
yeast. The data is what will be sent to the constructor of the ingredient defined by
>>> radd'fermentable'name: 'Pale malt'weight: 4.0yield: 75color: 3.5;>>> rfermentables<BrauhausFermentable object 'Pale malt'>>>> radd'hop'name: 'Cascade'weight: 0.028time: 60aa: 5.3form: 'pellet';>>> radd'spice'name: 'Coriander'weight: 0.014time: 5form: 'ground';>>> radd'yeast'name: 'Wyeast 3056'type: 'ale'form: 'liquid'attenuation: 75;
Get the recipe batch size in gallons. Shortcut for
Get the recipe boil size in gallons. Shortcut for
Get the total number of whole bottles (i.e. servings) for this recipe. This is a shortcut that is equivalent to
Math.floor(r.batchSize / r.servingSize).
Calculate alcohol, bitterness, color, gravities, etc. This method must be called before trying to access those values. See the quick examples above for a more complete example of
>>> rcalculate>>> ribu28.5
Grade this recipe's completeness. Returned is a
Number, where a completely blank recipe is zero and the higher the number, the higher the recipe completeness / quality. Some items carry more weight than others.
Get the total grain weight in kg. Note that this only includes fermentables that are mashed or steeped. Things like malt extract syrup are excluded.
Scale a recipe and its ingredients to a new batch size and boil size in liters. Gravity and bitterness units are preserved. This does not recalculate the recipe, it merely adjusts various weights and volumes.
>>> rscale10 6.5>>> rcalculate>>> ribu28.5
Generate a brew timeline from a recipe. If
true, then generate the timeline in metric units, otherwise output imperial units. Returns a list of
[duration, description] items where
duration is a time in minutes from the start of the recipe and
description is the step description text.
>>> rtimeline0 'Heat 10l of water to 68C (about 20 minutes)'20 'Add 1kg CaraMunich (10 GU) and steep for 20 minutes'40.16 'Remove grains. This is now your wort. Top up to 10l and bring to a boil (about 12 minutes)'62.52 'Add 28g of Cascade hops (30 IBU)'
It's possible to display a human-friendly version of this information with some utility methods used in a loop. For example:
>>> timeline = rtimeline>>> for var x = 0; x < timelinelength; x++>>> var duration = timelinex0;>>> var description = timelinex1;>>> console.logBrauhausdisplayDurationduration 2 + ': ' + description;>>>start: Heat 10l of water to 68C about 20 minutes20 minutes: Add 1kg CaraMunich 10 GU and steep for 20 minutes40 minutes: Remove grains This is now your wort Top up to 10l and bring to a boil about 12 minutes63 minutes: Add 28g of Cascade hops 30 IBU
It is also possible to determine the hop additions relative to the start and end of the boil. This allows you to nicely display the boil additions as relative times (e.g. -60 minutes, -45 minutes, -5 minutes to the end of the boil). Anything before the
boilStartTime is the mash, steep, or heating to boil, while anything after the
boilEndTime is chilling, fermentation and bottling. The
brewDayDuration ends when fermentation begins. The exact point of bottling can be determined with a combination of
>>> timeline = rtimeline>>> console.logrboilStartTime62.52>>> console.logrboilEndTime122.52
Contributions are welcome - just fork the project and submit a pull request when you are ready!
First, create a fork on GitHub. Then:
git clone ...cd brauhausjsnpm install
Brauhaus uses the CoffeeScript Style Guide with the following exceptions:
cake build or
npm test you will see the output of CoffeeLint, a static analysis code quality tool for CoffeeScript. Please adhere to the warnings and errors to ensure your changes will build.
Before submitting a pull request, please add any relevant tests and run them via:
If you have PhantomJS installed and on your path then you can use:
CI=true npm test
Pull requests will automatically be tested by Travis CI both in Node.js 0.6/0.8/0.10 and in a headless webkit environment (PhantomJS). Changes that cause tests to fail will not be accepted. New features should be tested to be accepted.
New tests can be added in the
test directory. If you add a new file there, please don't forget to update the
test.html to include it!
You can generate a unit test code coverage report for unit tests using the following:
You can find an HTML report in the
coverage directory that is created. This report will show line-by-line code coverage information.
Please note that all contributions will be licensed under the MIT license in the following section.
Copyright (c) 2013 Daniel G. Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.