Skip to main content
marimo notebooks are reactive Python programs stored as .py files. This makes them easy to version control, diff, and integrate into your development workflow.

Creating a New Notebook

1

Start the editor

Create a new notebook with the marimo edit command:
If the file doesn’t exist, marimo will create an empty notebook. If it exists, marimo will open it for editing.
2

Open in browser

marimo will automatically launch your browser and open the notebook editor at http://localhost:2718.Use the --headless flag to prevent the browser from opening:
3

Add cells

Click the + button or press Ctrl/Cmd + K to add a new cell. Each cell can contain Python code that will execute reactively.

Notebook File Structure

marimo notebooks are pure Python files with a specific structure:
notebook.py
Each cell is a Python function decorated with @app.cell. Variables are automatically tracked and cells re-execute when their dependencies change.

Understanding Cells

Cell Functions

Each cell is defined as a function:
The function parameters (like __(mo, pd)) indicate which variables from other cells this cell depends on.

Variable Returns

Variables must be explicitly returned to be used by other cells:
Variables not included in the return statement are local to the cell and won’t be accessible elsewhere.

Anonymous Cells

Cells use __() as the function name by default. You can also name cells for better debugging:

Organizing Code

Markdown Cells

Use mo.md() to create formatted markdown content:

Code Organization

Follow these best practices:
  1. Import cells first: Place imports at the top
  2. One responsibility per cell: Keep cells focused on a single task
  3. Return only what’s needed: Don’t expose internal variables
  4. Use descriptive names: Name important cells for clarity

Cell Configuration

Hide Code

Hide cell code while showing output:

Disable Automatic Execution

Prevent a cell from running automatically:

Advanced: Script Metadata (PEP 723)

marimo notebooks can include dependency information using PEP 723 inline script metadata:
When you use --sandbox mode, marimo automatically manages these dependencies. See Package Management for details.

Creating from Templates

AI-Generated Notebooks

Generate a notebook from a text prompt:

Tutorial Notebooks

Open built-in tutorials:

Next Steps

Running Notebooks

Learn about different execution modes

Package Management

Manage dependencies in your notebooks