Most online board foot calculators give you four inputs for a single board and call it a day. That works for one plank, not when you are standing at a lumberyard trying to price out 14 rows of mixed 4/4 rough hardwood and 2x6 framing stock.
While building WoodLayoutCalc, I wanted every calculation to run locally in the browser with zero backend state, while still matching how woodworkers actually write dimensions: mixed fractions (7 1/4 or 7-1/4), hardwood quarter notation (4/4, 5/4, 8/4), and nominal vs. surfaced (actual) dimensional lumber.
Here is how the core math module handles those edge cases in plain TypeScript.
1. Parsing mixed fractions and quarter notation
People rarely type 7.25 when measuring with a tape. They type 7 1/4", 7-1/4, or 5/4 for rough-sawn hardwood thickness. A regular parseFloat() call stops at the space or slash and silently returns 7 or 5.
Instead of pulling in a math expression parser, a single regex handles decimals, simple fractions, mixed numbers, and trailing inch marks:
export function parseNumber(input: string): number { const s = input.trim().replace(/,/g, "").replace(/["″”]$/, "").trim(); if (!s) return NaN; const frac = /^(?:(\d+(?:\.\d+)?)[\s-]+)?(\d+)\s*\/\s*(\d+)$/.exec(s); if (frac) { const den = parseInt(frac[3], 10); if (den === 0) return NaN; const whole = frac[1] ? parseFloat(frac[1]) : 0; return whole + parseInt(frac[2], 10) / den; } if (!/^(\d+\.?\d*|\.\d+)$/.test(s)) return NaN; return parseFloat(s); } With this function:
-
"7 1/4"and"7-1/4"both resolve to7.25. -
"4/4"resolves to1,"5/4"to1.25, and"8/4"to2. -
"1/0"or malformed strings returnNaNso invalid rows are flagged instead of throwing.
2. Nominal vs. actual PS 20 lumber sizing
Lumber yards price dimensional softwood by its nominal size (2×4, 2×6, 1×12), even though a kiln-dried, surfaced 2×4 measures 1.5" × 3.5" under the U.S. PS 20 standard.
If someone enters a 2×4×8' row, they usually want the nominal board-foot total for billing (2 × 4 × 8 ÷ 12 = 5.33 BF), though sometimes they want the surfaced volume (1.5 × 3.5 × 8 ÷ 12 = 3.50 BF). Keeping a small lookup table lets users toggle between nominal and actual modes without retyping their cut list:
export const DIMENSIONAL_LUMBER: Record< string, { nominal: [number, number]; actual: [number, number] } > = { "1x4": { nominal: [1, 4], actual: [0.75, 3.5] }, "1x6": { nominal: [1, 6], actual: [0.75, 5.5] }, "1x12": { nominal: [1, 12], actual: [0.75, 11.25] }, "2x4": { nominal: [2, 4], actual: [1.5, 3.5] }, "2x6": { nominal: [2, 6], actual: [1.5, 5.5] }, "2x8": { nominal: [2, 8], actual: [1.5, 7.25] }, "2x12": { nominal: [2, 12], actual: [1.5, 11.25] }, "4x4": { nominal: [4, 4], actual: [3.5, 3.5] }, }; 3. Multi-row totals with waste and cost
Once each row is normalized to inches (thickness and width) and feet (length), the board-foot formula is straightforward:
export function boardFeet(tIn: number, wIn: number, lFt: number): number { return (tIn * wIn * lFt) / 12; } For multi-row lists, waste percentage (0%–100%) is clamped and applied on top of raw board feet before multiplying by per-BF cost. Totals also convert cleanly to cubic feet (BF / 12) and cubic meters (BF * 0.00235974) for metric workflows.
You can test the live calculator or check the step-by-step board foot formula guide at WoodLayoutCalc.