marimo convert
Convert Jupyter notebooks, Markdown files, or Python scripts to marimo notebook format.Usage
Arguments
FILENAME - File to convert (required)- Supported formats:
.ipynb,.md,.qmd,.py - Can be a local file path
- Can be a GitHub URL to a notebook
Options
-o, —output PATH - Output file path- Type: Path
- If not provided, the converted notebook is printed to stdout
- Parent directories will be created if they don’t exist
Supported Formats
Jupyter Notebooks (.ipynb)
- Converts Jupyter notebooks to marimo format
- Cell outputs are stripped during conversion
- Cell execution order is preserved
- Markdown cells are converted to marimo markdown cells
Markdown Files (.md, .qmd)
- Only
{python}fenced code blocks are converted to cells - Other content is ignored
- Example of supported syntax:
Python Scripts (.py)
- If already a valid marimo notebook: No conversion is performed
- Otherwise: Attempts conversion using py:percent format
- Preserves top-level comments and docstrings
- Supports
# %%cell delimiters
Examples
Convert Jupyter Notebook
Convert from GitHub
Convert Markdown
Convert Python Script
Using Global Flags
Workflow Example
Important Notes
Reactivity Considerations
marimo’s reactive execution model differs from Jupyter’s linear execution:- Variables are immutable: Each cell defines variables only once
- No mutation across cells: Code that modifies variables across multiple cells will need refactoring
After Conversion
- Review the converted notebook for any issues
- Refactor code that mutates variables across cells
- Test the notebook to ensure it works as expected
- Enjoy marimo’s reactive features!
Dependencies
For Python Script Conversion
Converting py:percent format Python scripts requiresjupytext:
jupytext is not installed, marimo will provide installation instructions.
Error Handling
Syntax Errors
If the input file has syntax errors:Invalid File Type
Already a marimo Notebook
Tips
- Always review converted notebooks for potential issues
- Use
-oto save the output, or pipe to inspect the conversion - For large Jupyter notebooks, consider splitting into smaller marimo notebooks
- Test converted notebooks thoroughly, especially if they have complex dependencies
Related Commands
- marimo edit - Edit converted notebooks
- marimo export - Export marimo notebooks to other formats