https://github.com/sbryngelson/ffmt
A fast Fortran formatter, written in Rust
https://github.com/sbryngelson/ffmt
cli-tools code-formatter formatter fortran hpc rust rust-crate scientific-computing
Last synced: 7 days ago
JSON representation
A fast Fortran formatter, written in Rust
- Host: GitHub
- URL: https://github.com/sbryngelson/ffmt
- Owner: sbryngelson
- License: mit
- Created: 2026-03-20T05:38:23.000Z (19 days ago)
- Default Branch: master
- Last Pushed: 2026-03-31T21:03:33.000Z (8 days ago)
- Last Synced: 2026-03-31T23:48:32.422Z (7 days ago)
- Topics: cli-tools, code-formatter, formatter, fortran, hpc, rust, rust-crate, scientific-computing
- Language: Rust
- Homepage: https://ffmt-fortran.readthedocs.io
- Size: 869 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ffmt
[](https://pypi.org/project/ffmt/)
[](https://github.com/sbryngelson/ffmt/actions/workflows/ci.yml)
[](https://opensource.org/licenses/MIT)
[](https://github.com/marketplace/actions/ffmt-fortran-formatter)
[](https://ffmt-fortran.readthedocs.io)
A fast, configurable Fortran formatter with support for Fypp, Doxygen, and OpenACC/OpenMP directives. Written in Rust. Installable via `pip`.
**[Documentation](https://ffmt-fortran.readthedocs.io)** | **[Configuration](https://ffmt-fortran.readthedocs.io/en/latest/configuration/)** | **[Changelog](https://github.com/sbryngelson/ffmt/releases)**
## Installation
```bash
pip install ffmt
```
Or via Cargo:
```bash
cargo install ffmt
```
## Quick start
```bash
ffmt src/ # format in-place
ffmt --check src/ # CI mode (exit 1 if changes needed)
ffmt --diff src/ # show colored diff
ffmt -j 8 src/ # parallel
cat file.fpp | ffmt - # stdin/stdout
```
## Features
- **Code** -- indentation, whitespace normalization, keyword casing, named ends, line wrapping, operator modernization (`.eq.` -> `==`), double-colon enforcement, trailing semicolon removal
- **Comments** -- rewrapping, inline spacing (S102), `!<` alignment, `!&`/`& !` cleanup, format suppression (`! ffmt off/on`)
- **Structure** -- blank line management around openers/closers/`#ifdef`, declaration `::` alignment, declaration/use compaction
- **Preprocessor** -- Fypp (`#:if`, `$:`, `@:`), C preprocessor (`#ifdef`), OpenACC (`!$acc`), OpenMP (`!$omp`)
- **Opt-in** -- multi-statement splitting, assignment alignment, `&` column alignment, use-statement reformatting
Most options accept `true`, `false`, or `"preserve"`. See the [configuration reference](https://ffmt-fortran.readthedocs.io/en/latest/configuration/) for all options.
## Configuration
Create `ffmt.toml` or add `[tool.ffmt]` to `pyproject.toml`:
```toml
indent-width = 4
line-length = 132
keyword-case = "lower"
modernize-operators = true
enforce-double-colon = true
[whitespace]
relational = true
multdiv = false
```
## CI
```yaml
# GitHub Actions
- uses: sbryngelson/ffmt@latest
with:
args: "--check src/"
```
```yaml
# pre-commit
repos:
- repo: https://github.com/sbryngelson/ffmt
rev: v0.3.5
hooks:
- id: ffmt
```
## Other Fortran formatters
| Formatter | Language | Status | Notes |
|-----------|----------|--------|-------|
| [fprettify](https://github.com/fortran-lang/fprettify) | Python | Unmaintained | Free-form only. Fypp support. |
| [findent](https://github.com/wvermin/findent) | C | Active | Indentation and fixed/free conversion. |
| [Codee Formatter](https://www.codee.com) | Proprietary | Active | Commercial. Tree-sitter based. |
| [LFortran fmt](https://lfortran.org) | Rust | In development | AST-based. |
| [Fortitude](https://github.com/PlasmaFAIR/fortitude) | Rust | Active | Linter with auto-fix. |
## License
MIT