- TypeScript 66.7%
- MDX 22.7%
- Vue 4%
- CSS 3%
- Astro 3%
- Other 0.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
CI / Build & Test (push) Successful in 7m0s
Reviewed-on: #330 |
||
| .changeset | ||
| .forgejo | ||
| .github | ||
| audit | ||
| conformance | ||
| editors | ||
| fuzz | ||
| packages | ||
| scripts | ||
| .git-blame-ignore-revs | ||
| .gitignore | ||
| biome.json | ||
| bun.lock | ||
| CHANGELOG.md | ||
| changeset-utils.ts | ||
| check-changesets.ts | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| demo.gif | ||
| deploy.sh | ||
| deprecations.yaml | ||
| generate-release-note.ts | ||
| gram-logo.png | ||
| lefthook.yml | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| renovate.json | ||
| screenshot.png | ||
| SECURITY.md | ||
| tsconfig.base.json | ||
| tsconfig.build.json | ||
| turbo.json | ||
Gram
Code your recipes.
An open-source recipe DSL (GPL-3.0) for developers who cook, and for anyone building recipe tooling. Gram compiles plain-text .gram files into strict, deterministic JSON, backed by a CLI, a Language Server (LSP), and editor integrations.
Website • Playground • Documentation
Note
Gram is an independent open-source project. Primary development happens on Forgejo, with read-only automatic mirrors on GitHub and Codeberg.
Issues and pull requests are handled on Forgejo. See CONTRIBUTING.md if you want to get involved.
Quick example
Gram works for simple everyday recipes and shines on technical cooking: baking, pastry, fermentation, shared base recipes, or multi-day prep.
## Dough ->&dough
[Mix] @*bread flour{500g}, @water{70% @&bread flour}, and @salt{2% @&bread flour}.
[Ferment] Cold retard for ~_{12-24h} at ^{4°C}.
## Bake
[Bake] The &dough at ^{250°C}(stone) for ~{6min} until ={blistered}.
From those 6 lines, Gram resolves 350g of water and 10g of salt from baker's percentages, recalculates every quantity whenever the flour weight changes, separates active work from the 12-24h cold retard to plan two kitchen visits backward from dinner, estimates nutrition from your local ingredient database, and outputs structured JSON.
You can edit live recipes in the browser with no install at gram-lang.org/play.
What Gram does
- Plain text you own: recipes live as readable
.gramfiles in Git (ingredients, cookware, temperatures, and target states like={blistered}), with no cloud, no account, and no proprietary database. - Baker's math and unit ratios: declare relative percentages (
@water{70% @&flour}), unit ratios (@garlic{1 clove / 100g @&beef},~{15min / 500g @&roast}), and compound quantities (@flour{1 cup + 2 tbsp}). - Modular recipes and references: import base recipes with
@use "./bases/shortcrust.gram" as &crust(with automatic yield scaling and unified shopping lists), pass intermediate preparations between steps (->&dough), and split composite ingredients (<@lemons{2}) without double-counting them. - Backward (ALAP) scheduling and run sheets: separate active steps (
~{35min}) from passive waits (~_{12-24h}). Gram schedules backward from your serving time, stretches range waits to keep active work out of the night, and produces a day-by-day run sheet telling you when to be in the kitchen and what to take out. - 100% deterministic, offline core: parsing, compiling, scaling, scheduling, nutrition analysis, and rendering run locally with no network calls and no AI. Optional AI-assisted commands (
gram import,gram db enrich,gram db lint) live only in the CLI and use your own API key.
Tooling
Editors and language server
- VS Code & Open VSX (VS Code Marketplace · Open VSX for VSCodium, Cursor, Windsurf, Positron): real-time diagnostics, autocomplete (ingredients from your YAML database, units,
@usepaths), hover info (nutrition, scaled weights, ratios), rename (F2), format on save, and side-by-side Live Preview and Run Sheet views. - Neovim, Helix and Zed: syntax highlighting and queries via
tree-sitter-gram, plus the dedicatedzed-gramextension for Zed. - Standalone LSP (
@gram-lang/language-server): standard Language Server Protocol server usable from any editor. See the editors guide for setup instructions.
CLI (@gram-lang/cli)
Available on npm, running on Node.js (>=22) or Bun:
gram check,gram format,gram build: validate syntax, format.gramfiles canonically, and compile recipes to JSON.gram view,gram export,gram print: render a recipe or its run sheet (--view run-sheet) in the terminal, or export to HTML, Markdown, plain text, and print layout.gram plan: schedule a recipe backward from a serving time (--serve) within your available hours (--available), or find serving times that work (--find).gram cook: step-by-step terminal cooking mode with live timers and target-state reminders.gram scale,gram diff,gram shop,gram suggest: resize recipes, diff versions semantically, aggregate shopping lists across files, and filter recipes by ingredients on hand.gram db syncandgram db validate: scan recipes for missing entries iningredients.yamland validate the database offline.gram import,gram db enrich, andgram db lint(optional, BYOK): convert web URLs, JSON-LD files, or YouTube videos into.gramfiles, suggest missing density and nutrition data, or catch duplicates and plural mismatches iningredients.yamlwith interactive review before writing.
Try it out
Start a CLI project
npm install -g @gram-lang/cli
gram init
# or with Bun
bun add -g @gram-lang/cli
gram init
Use the compiler in JavaScript / TypeScript
import { getAST } from '@gram-lang/parser';
import { compile } from '@gram-lang/kitchen';
const ast = getAST('## My Recipe\n\n[Mix] @flour{200g} and @water{100g}.');
const result = compile(ast);
console.log(result.shopping_list);
Run the docs and playground locally
Contributing to the monorepo requires Bun (see CONTRIBUTING.md):
bun install
bun run dev
Documentation
The full language specification, guides, and CLI reference are at gram-lang.org/docs/ (source in packages/docs/).
Project structure
| Package | Version | Description |
|---|---|---|
@gram-lang/parser |
Ohm.js parser generating the typed recipe AST. | |
@gram-lang/modules |
Resolves @use imports and composes multi-file recipe ASTs. |
|
@gram-lang/kitchen |
Compiler turning the AST into compiled recipe JSON. | |
@gram-lang/scheduler |
Scheduling engine: backward ALAP timeline, availability projection, and run sheet grouping. | |
@gram-lang/format |
Canonical .gram source formatter. |
|
@gram-lang/analyzer |
Mass standardization, yield metrics, nutrition estimation, and semantic recipe diffing. | |
@gram-lang/renderer |
Display layer: recipe and run sheet views in HTML, Markdown, plain text, and print. | |
@gram-lang/cli |
Command-line interface (gram). |
|
@gram-lang/i18n |
Unit normalization, duration parsing, and EN/FR localization. | |
@gram-lang/language-server |
Language Server Protocol implementation. | |
vscode-extension |
Visual Studio Code extension. | |
docs |
- | Astro/Starlight documentation site and browser playground. |
Development, testing and roadmap
Every push and pull request runs through Forgejo Actions:
- Linting and formatting: Biome (
bun run lint). - Typechecking: across the monorepo (
bun run typecheck). - Unit tests: per-package suites (
bun test). - Conformance suite: language-agnostic golden tests (
bun run conformance) pinning AST, compiled JSON, and analyzed JSON outputs. - Deterministic fuzzer: property-based fuzzing across the parser, compiler, analyzer, linter, and formatter (
bun run fuzz).
TypeScript today, Rust next
Gram started in TypeScript, and keeping a single implementation while the language still evolves makes iteration fast and lets the full compiler run natively in the browser playground. A Rust port of the core (parser, kitchen, analyzer, i18n) is planned once the spec settles: the language-agnostic conformance suite and tree-sitter-gram are already in place so the transition can happen without breaking JSON contracts or npm packages.
Acknowledgments
- Cooklang: for pioneering plain-text recipe markup and inspiring Gram's initial syntax.
- Ohm.js: for a readable PEG grammar that is pleasant to iterate on.
- AI coding tools: Used throughout development to build and maintain the codebase, checked by the conformance suite, fuzzer, and CI tests.
Community and support
- Bugs and feature requests: open an issue on Forgejo.
- Discussions: there is a Discord server and r/gramlang for questions, recipes, and feedback.
License
Gram is licensed under the GPL-3.0 license. Recipes you write in .gram belong entirely to you.