renpyfmt is an opinionated source code formatter for Ren'Py script.
It ships with a complete, standalone parser for the Ren'Py language, allowing for deep understanding of the code and thus proper formatting. Embedded Python blocks and Python files are formatted via ruff.
| OS | amd64 | aarch64 |
|---|---|---|
| Linux | ✅ | ✅ |
| macOS | ✅ | ✅ |
| Windows | ✅ | ❌ |
renpyfmt format [PATHS]...
renpyfmt check [PATHS]...
renpyfmt format - --stdin-filename script.rpy
renpyfmt check - --stdin-filename script.rpyformat rewrites files in place, or writes formatted output to stdout when reading from stdin.
check performs the same discovery and formatting pass without writing changes. It exits with:
0when every input is already formatted1when one or more inputs would change2on real errors
Stdin input always requires --stdin-filename <PATH> so renpyfmt can choose .rpy vs .py formatting and discover Ruff configuration from the right directory.
To format .rpy files from VS Code, install:
- a Ren'Py language extension for
.rpyfiles - Advanced Local Formatters
Then add this to .vscode/settings.json:
{
"advancedLocalFormatters.formatters": [
{
"command": ["renpyfmt", "format", "-", "--stdin-filename", "$absoluteFilePath"],
"languages": ["renpy"]
}
],
"[renpy]": {
"editor.defaultFormatter": "webfreak.advanced-local-formatters",
"editor.formatOnSave": true
}
}If your Ren'Py extension uses a different language id than renpy, replace it in both places above. If renpyfmt is not on your PATH, use an absolute path to the executable instead of renpyfmt.
brew install kobaltcore/renpyfmt/renpyfmtrenpyfmt comes with several installation options for the various supported platforms. Please check out the available options for the latest release.
Download the pre-built binaries for your operating system and architecture for the latest release and extract the resulting tar file.
After this, either add the binaries to your PATH or use them directly from within the download directory.
