Skip to content

What is Gram?

Gram is an open-source declarative DSL (Domain-Specific Language) for cooking recipes, built for cooks and developers alike.

Most recipe formats are just static blocks of text. Gram takes instructions written in plain text and compiles them into structured, calculated, relational, and schedulable data, ready to drive a shopping list, a kitchen timeline, or an entire application.

Cooking is a bit like an algorithm: raw ingredients go in, a finished dish comes out. I love cooking, and I wanted a tool that brings the rigor of code to creativity in the kitchen.

Plain-text formats like Cooklang showed how readable text-based recipes can be for everyday cooking, while Cooking for Engineers showed how much clarity comes from separating ingredients, intermediate components, and steps. When a recipe grows into multi-day pastry work, baker’s math, or tight timing, prose alone breaks down.

Because Gram compiles a .gram file into a deterministic JSON tree, the data and calculations stay independent from how you present them. Gram ships a few reference views (like a recipe layout and a run sheet) but the real goal is giving any UI a reliable foundation to build on.

Gram brings five core ideas to recipe authoring:

  • Relational variables (->&, &): Capture a dough or sauce in one step (->&hot milk{}) and reuse it later (&hot milk{}) without duplicating ingredients on your shopping list.
  • Physical accuracy and ratios: Bundle parts into whole purchases (@egg yolks{6}<@eggs{6} aggregates to 6 eggs), standardize volumes to mass, combine units (1 cup + 1 tbsp), and express formulas as percentages (70% @&flour) or unit ratios (15 g / L @&water, ~{15 min / 500 g @&roast}).
  • Strict data contracts: Explicit markers keep ingredients (@), cookware (#), timers (~), temperatures (^), and target states (={...}) unambiguous, separating how long a step should take (~_baking{30 min - 1 h}) from the sensory cue that tells you it is done (={golden brown}).
  • Modular recipes (@use): Split shared bases (pastries, stocks, sauces) into their own .gram files. Gram scales them automatically to the weight your dish asks for, merges raw ingredients onto your shopping list, and lets you mark bases already on hand (--stock).
  • ALAP (As Late As Possible) scheduling: Backward-schedule prep and resting phases (~{-1d}, ~_) so every component converges at serving time, mask prep inside passive rests, avoid equipment contention on named tracks (~_baking), and project plans onto your real availability.

Gram stays readable as plain text while packing structured data underneath. Here is a classic French pastry recipe (Bordeaux cannelés) alongside what Gram produces from it:

---
title: 'Cannelés'
portions: 10
---

## Batter ~{-1d} ->&batter

[Mix] In a #mixing bowl{}, combine the @flour{300 g}, @sugar{500 g}, and @salt{3 g}. ->&dry ingredients{}

[Heat] In a #large saucepan{}, bring the @milk{1 l}, @butter{100 g}, and @vanilla bean{1}(split and scraped) to ^{185°F}. ->&hot milk{}

[Mix] Pour the &hot milk{} over the &dry ingredients{} all at once. Whisk vigorously.

[Incorporate] Add the @egg yolks{6}<@eggs{6} and the @rum{100 ml}.

[Rest] Cover with #plastic wrap{} touching the surface and chill in the refrigerator for at least ~_refrigerator{24 h}.

## Baking

[Preheat] The #oven to ^{465°F}.

[Grease] The #cannelé molds{38}(lunch/4.5cm).

[Fill] Pour the &batter into the molds, filling them 3/4 full.

[Bake] In the #&oven at ^{465°F} for ~_baking{10 min}.

[Cook] Lower the temperature to ^{360°F} and continue for ~_baking{30 min - 1 h}, until ={dark mahogany}.

From one readable file, Gram derives the shopping list, links the batter across two days, and outputs structured scheduling data (see Data formats for the complete JSON schemas).

  • Editor and terminal: Write with live preview, run sheets, and diagnostics in VS Code, or use the CLI for interactive cooking, meal planning, shopping lists, formatting, and AI recipe import.
  • Embeddable engine: Import only the lightweight ESM packages you need in Node.js, Bun, Deno, or the browser, from the parser and compiler to the scheduler and renderer. Explore the API reference or The Gram lifecycle.