Plain-text recipe DSL (GPL-3.0) compiling .gram files into deterministic JSON. Includes the compiler, backward scheduler, CLI, LSP, and VS Code extension. https://gram-lang.org
  • TypeScript 68%
  • MDX 22%
  • Vue 3.6%
  • CSS 2.8%
  • Astro 2.7%
  • Other 0.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-05-10 13:53:24 -10:00
data fix: Defined wheat-flour-t55 as default "flour" 2026-01-17 20:20:03 +01:00
docs docs: add technical documentation for compiler options and ingredient database 2026-05-10 13:53:24 -10:00
examples fix: Updated examples recipes for better use of syntax 2026-01-03 14:16:14 +01:00
packages fix: handle empty ingredient masses as zero and improve undefined mass checks in compiler metrics 2026-05-10 13:16:59 -10:00
.gitignore Initial release: Specification, Parser core, Playground and VSCode Extension 2025-12-28 21:28:39 +01:00
bun.lock feat: implement unit resolution, add compiler options for mass normalization, and update relative ingredient quantity calculations. 2026-05-10 12:26:56 -10:00
CONTRIBUTING.md docs: Modified forgotten references to github 2026-01-06 17:13:46 +01:00
deploy.sh fix: Updated playground deployment to exclude node_modules 2026-01-06 23:39:37 +01:00
gram-banner.png docs: Added banner + syntax example correction 2025-12-29 20:25:12 +01:00
LICENSE Initial commit 2025-12-28 20:39:17 +01:00
package-lock.json style: Playground removed footer top border 2026-01-18 15:09:30 +01:00
package.json chore: Updated workspaces and scripts to reflect new folder structure 2026-01-02 20:18:21 +01:00
README.md docs: Updated why section 2026-01-07 10:27:32 +01:00
tsconfig.base.json refactor: Centralized tsconfig with base 2026-01-02 20:19:28 +01:00

GRAM - General Recipe Abstract Markup

A strictly typed, data-first recipe markup language for developers.

Status Open Source License

Gram Banner

GRAM is designed to write structured, machine-readable recipes without sacrificing readability. It treats recipes as code, compiling ingredients, instructions, and cookware into a strict AST (Abstract Syntax Tree) for precise analysis, scaling, and shopping list generation.

👉 Try the Online Playground (or run it locally)

🚧 Project Status: Active Development GRAM is currently in an Alpha stage. The syntax specification is stabilizing, but the parser logic is actively being refined. Breaking changes may occur. This is an Open Source project. We believe standardizing recipe data requires a community effort. Feedback, feature requests, and code contributions are highly welcome!

Please see CONTRIBUTING.md for more information on how to contribute to GRAM.


📚 Documentation

The full technical documentation is available in the docs/ folder.


🥘 Why GRAM?

Inspired by the excellent Cooklang, GRAM evolves the concept by enforcing a strict schema and advanced logic capabilities.

While Cooklang focuses on natural language fluidity, GRAM prioritizes data integrity and computational logic:

  1. Data vs. Narrative: Clear separation between ingredients (@flour{200g}) and instructions.
  2. Mise en Place: Distinguishes between the Shopping List (Aggregated totals) and the Section List (What you need on the table right now).
  3. Advanced Syntax Features:
    • Actions ([Mix]): Highlights the main method used in a step
    • References (@&): Reuse previously measured ingredients without doubling the shopping list amount.
    • Intermediate Preparations (->&dough): Chain recipe parts like variables.
    • Relative Quantities: Define @water{60% @flour} for dynamic bakers math.
    • Composites: Handle "Zest of 1 lemon" and "Juice of 2 lemon" implying "Buy 2 Lemon".
  4. Automated Insights:
    • Mass Unification: Automatically converts volumes and units to grams (e.g., 1 cup flour -> 125g).
    • Yield Management: Understands that buying 1 avocado results in ~135g of edible flesh (Purchasing vs. Net Mass).
    • Nutritional Estimation: Automatically calculates calories and macros based on an integrated ingredient database (POC).
    • Scheduling: Distinguishes Active Time (labor), Prep Time (mise en place) and Cook Time (actual cooking) from Total Time (including background tasks like rising or marinating).

→ See the full feature list for more details.


⚡ Quick Syntax

## Dough {T-2h} 

[Mix] The @flour{200g} and @water{100ml}. ->&dough{}

[Add] The &dough{} to a #bowl{}.

[Rest] For ~{30min}.

[Bake] In the #oven{} at !{200°C}.

You can find more real-world examples in the examples/ directory at the root of the project.


🛠️ Project Structure

This monorepo contains the following packages in packages/:

  • parser/: The core parser. Converts GRAM strings to an AST (Abstract Syntax Tree).
  • compiler/: The compiler logic. Transforms the AST into the final Shopping List and Instructions JSON.
  • playground/: A web-based IDE to write GRAM and visualize the output (JSON, Markdown, Preview).

And:

  • vscode-extension/: The Visual Studio Code extension (located in packages/vscode-extension/).

🤝 Contributing

We need your help to make GRAM the standard for structured recipes!

Whether you are a developer, a chef, or a data enthusiast, your contributions are welcome.

  • Found a bug? Open an issue to help us squash it.
  • Have an idea? Start a discussion on syntax improvements.
  • Want to code? Fork the repo and submit a Pull Request.

📦 Try it out

1. Run the Playground locally

To inspect the parser or test your recipes in the web-based playground IDE:

# Install dependencies for all packages
npm install

# Build parser, compiler, and playground
npm run build 

# Run the playground
npm run dev

2. Use the Parser

(See parser/README.md for API details)

const { getAST } = require('gram-parser');
const { compile } = require('gram-compiler');

const ast = getAST(myGramString);
const result = compile(ast);

console.log(result.shopping_list);

👏 Acknowledgments

GRAM stands on the shoulders of giants.

  • Cooklang: For pioneering the concept of a recipe markup language. GRAM was heavily inspired by their concise syntax.
  • Ohm.js: For making parsing accessible and robust.
  • LLM Assistance: This project was developed with the assistance of AI for rapid prototyping, refactoring, and generating test cases. All logic and architecture were strictly verified by humans.

License

Distributed under the GPL-3.0 License.