Freedom251 › Code Formatting Tools
Fourmolu

What Fourmolu is
Fourmolu is a configurable formatter for Haskell source code and a fork of Ormolu. It uses GHC’s parser and aims for minimal diffs, repeatable formatting, and robustness on large projects. Formatting options can be set in a fourmolu.yaml file or supplied through command-line options. Controls cover indentation, line length, import grouping, record layout, Haddock comments, Unicode output, and operator fixities. Fourmolu can find a source file’s Cabal file and use its default extensions and dependencies to help determine operator fixities. Magic comments can skip formatting for selected code, and command-line options can target a line region. The project offers an interactive browser demo and documents editor integration through Haskell Language Server. Installation guidance covers GHCup, Cabal, Stack, and dotslash; a GitHub Action is recommended for keeping a project formatted. Its listed current release is v0.21.0.0. CPP handling is experimental and limited to simple cases where conditionals surround top-level declarations. Output always uses LF line endings, so check mode can fail on otherwise formatted files with CRLF endings.
Who it suits
Fourmolu suits Haskell developers who want configurable formatting, including options informed by a project’s Cabal file. It may also fit teams seeking editor or GitHub Actions integration.
What it does well
- Offers an interactive browser demo.
- Formatting options can be configured in YAML or CLI.
- Can use Cabal defaults and dependencies for fixities.
- Supports selective formatting with comments or line regions.
- Editor integration through Haskell Language Server is documented.
What to know first
- CPP handling is experimental and limited to simple cases.
- Always outputs LF line endings.
- Check mode can fail on CRLF files.
Limits
CPP formatting is experimental and works only in simple cases where conditionals surround top-level declarations. Output always uses LF line endings, so check mode can fail on otherwise formatted files with CRLF endings.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| Fourmolu | Open-source Haskell formatter | Free |
As fourmolu.github.io lists them, read 11 Oct 2026. The maker's own page has the final word.
Getting started
- Open the interactive browser demo at https://fourmolu.github.io/.
- For local installation, follow the project’s GHCup instructions, or use its documented Cabal, Stack, or dotslash routes.
- Set formatting preferences in fourmolu.yaml or with command-line options.
- For editor integration, configure Haskell Language Server with haskell.formattingProvider set to fourmolu.
- For project CI, use the recommended run-fourmolu GitHub Action.
Fourmolu is a free, open-source formatter for Haskell source code, best suited to developers and teams who want configurable formatting built into their existing workflow. Its project-aware formatting and editor and CI options make it practical for routine use, but projects relying on complex CPP or CRLF line endings should look carefully at its limits.
Overview
As a configurable fork of Ormolu, Fourmolu uses GHC’s parser and aims to keep changes small, produce the same output on repeat runs, and handle large projects and modern Haskell dialects. Those goals make it a sensible choice for teams introducing formatting to an established codebase: smaller diffs are easier to review, while idempotence helps keep routine formatting from creating churn.
Settings can be stored in fourmolu.yaml or passed as command-line options. Fourmolu also locates the relevant Cabal file to read default language extensions and dependencies, helping it determine operator fixities in the context of the project. That Cabal awareness is useful when formatting depends on project-specific language settings, but it also makes the tool most compelling within a Cabal-based Haskell workflow.
Key features
- Configurable style: Controls cover indentation, line length, import grouping, record layout, Haddock comments, Unicode output, and operator fixities. Teams can shape the formatter around meaningful project conventions rather than accepting a single fixed style.
- Selective formatting: Magic comments can exempt selected code, and command-line options can target a specified line region. This gives developers a way to work around code that should not be reformatted or limit changes to part of a file.
- Browser demo: The interactive web app offers configurable formatting and program options, providing a way to explore results without first installing the formatter.
- Workflow integration: The README describes editor integration through Haskell Language Server by setting haskell.formattingProvider to fourmolu, and recommends the run-fourmolu GitHub Action for keeping projects formatted. These options help teams make formatting part of editing and CI rather than a separate manual step.
- Installation choices: The project recommends GHCup and also documents installation through Cabal, Stack, and dotslash, leaving Haskell developers several ways to add it to a project environment.
Pricing
Fourmolu is free: its open-source plan costs nothing. There is no paid tier or trial to weigh, making it suitable for individual developers and teams that need a Haskell formatter without a software fee. The trade-off is that users choose it for its formatting capabilities and workflow fit, not for a paid support or service tier.
Platforms
The browser demo makes Fourmolu usable on the web, while the project supports Linux and Windows. Its library API is also available for integration. The installation and editor options make it particularly relevant to Haskell development environments; macOS is not among the supported platforms stated for this entry.
Who it's for
Fourmolu is a strong fit for Haskell developers who want configurable project-wide rules, Cabal-aware handling of extensions and operator fixities, and editor or CI integration. Teams that value smaller formatting diffs and repeatable output should find its design goals relevant. It is less suitable for codebases that depend on complex CPP conditionals or require CRLF-preserving formatting.
Pros and cons
Pros
- Project-aware formatting: Reading Cabal defaults and dependencies helps the formatter account for language extensions and operator fixities.
- Useful style control: Options span common layout and presentation choices, with magic comments and region formatting for selective work.
- Multiple integration paths: Browser, editor, CI, and several installation methods can bring formatting into different stages of a Haskell workflow.
- No software cost: The open-source formatter is free for individual and team use.
Cons
- CPP support is experimental: It works only in simple cases where conditionals surround top-level declarations, limiting its fit for projects with more complex CPP use.
- LF-only output: Fourmolu always writes LF line endings, so check mode can fail on otherwise formatted files using CRLF.
- Haskell-specific: It formats Haskell source, so teams working in other languages need a different tool for those files.
Alternatives
Ormolu is the closest alternative for teams seeking a free, open-source Haskell formatter; choose between the two based on the configuration and workflow you need. For other language ecosystems, Black is a free Python code formatter, Fantomas formats F# source as a .NET tool, goimports is a free command-line tool, and rustfmt is an alternative for Rust projects. Prettier is another open-source code formatter with enterprise support and maintenance offered through Tidelift Subscription. Ruff and Accessibility Test Framework for Android are also listed as alternatives.
Browse more options in Code Formatting Tools.
Verdict
Choose Fourmolu if you maintain Haskell code and want configurable, Cabal-aware formatting that can fit into editor and CI workflows without a license fee. Its project-aware behavior and selective formatting options are persuasive strengths. Look elsewhere if your code depends on complex CPP or if CRLF output is a requirement.
Verdict
Fourmolu offers configurable Haskell formatting, with browser, editor, and CI integration options. Its experimental CPP support and LF-only output are important constraints to consider.
Questions
How much does Fourmolu cost?
Fourmolu is free and open source; its listed plan is free.
Is there a browser version?
Yes. The project website provides an interactive browser demo with configurable formatting and program options.
Which platforms are supported?
The listed platforms are Linux, web, and Windows.
How can I install Fourmolu?
The project recommends GHCup and also documents installation through Cabal, Stack, and dotslash.
Can I use it in an editor or CI?
Editor integration is documented through Haskell Language Server. The project recommends the run-fourmolu GitHub Action for CI.
Who maintains Fourmolu?
The README credits Tweag I/O from 2018–2020 and Matt Parsons from 2020 onward.
Facts from Fourmolu's own pages
- Browser app
- The project provides a browser-based app, which is redeployed on each new commit to main and may include unreleased changes. · github.com, 11 Oct 2026
- Cabal awareness
- It locates the relevant Cabal file to read default language extensions and dependencies that help determine operator fixities. · github.com, 11 Oct 2026
- Cabal support
- Fourmolu locates the Cabal file for a source file and uses it to obtain default extensions and dependencies. · github.com, 10 Oct 2026
- CI integration
- The README recommends the run-fourmolu GitHub Action for keeping a project formatted. · github.com, 11 Oct 2026
- Configuration
- Settings can be provided in a fourmolu.yaml file or as command-line options. · fourmolu.github.io, 11 Oct 2026
- Current release
- The site lists v0.21.0.0 as the current release. · fourmolu.github.io, 10 Oct 2026
- Editor integration
- Fourmolu can integrate with editors through Haskell Language Server by setting haskell.formattingProvider to fourmolu. · github.com, 11 Oct 2026
- Formatting controls
- It offers configurable options for indentation, line length, imports, records, comments, and other formatting choices. · fourmolu.github.io, 11 Oct 2026
- GitHub Actions
- The README recommends run-fourmolu to ensure a project is formatted with Fourmolu. · github.com, 10 Oct 2026
- Installation
- The project documents installation through GHCup, Cabal, Stack, and dotslash. · github.com, 11 Oct 2026
- Limitation
- CPP support is experimental and works only in simple cases where conditionals surround top-level declarations. · github.com, 11 Oct 2026
- Limitations
- The README describes CPP support as experimental and says it works only in simple cases where CPP conditionals surround top-level declarations. · github.com, 10 Oct 2026
- Line endings
- Fourmolu always outputs LF line endings, so check mode can fail on otherwise formatted files with CRLF endings. · github.com, 11 Oct 2026
- Maintainer attribution
- The README credits Tweag I/O from 2018–2020 and Matt Parsons from 2020 onward. · github.com, 11 Oct 2026
- Project context
- Fourmolu uses GHC's parser and aims for minimal diffs, idempotent formatting, and support for modern Haskell dialects. · github.com, 11 Oct 2026
- Project metadata
- The repository README says the formatter uses GHC's parser and aims for minimal diffs, idempotence, and robustness on large projects. · github.com, 10 Oct 2026
- Purpose
- Fourmolu formats Haskell source code and is a configurable fork of Ormolu. · fourmolu.github.io, 11 Oct 2026
- Selective formatting
- Magic comments can disable formatting for selected top-level definitions, and command-line options can format a chosen line region. · github.com, 11 Oct 2026
- Support and contributions
- The project invites users to request options and contribute through pull requests. · github.com, 11 Oct 2026
- Support channel
- The README invites users to report desired options and contributions through the project. · github.com, 10 Oct 2026
Where Fourmolu stands on Freedom251
- Code Formatting Tools#12 of 34