Haskell Code Formatter
Format and pretty-print Haskell source — consistent operator spacing, sorted/deduplicated LANGUAGE pragmas, sorted import blocks, and blank-line collapsing, approximating Fourmolu/Ormolu conventions. Includes basic syntax validation and a long-line report. Runs entirely in your browser.
Input
Output
| Issue |
|---|
| No data yet |
Guides
Paste inconsistently spaced Haskell source and get back a cleanly formatted module — consistent operator spacing around ->, <-, ::, =, comparison and arithmetic operators, sorted and deduplicated LANGUAGE pragmas, alphabetically sorted import blocks, and collapsed blank-line runs — approximating the conventions of Fourmolu/Ormolu. A quick validation pass flags unbalanced brackets and unterminated strings or block comments. Everything runs locally in your browser.
How to use it
- Paste your Haskell (
.hs) source. - Choose 2 spaces (Fourmolu's default) or 4 spaces (Ormolu's default) for indentation.
- Set the max line length used to flag overly long lines in the validation report (100 is Fourmolu/Ormolu's default).
- Toggle sort imports, sort/dedupe LANGUAGE pragmas, and collapse blank lines as needed.
- Check the Validation panel for syntax issues, then copy or download the formatted result.
What it formats
- Type signatures, function definitions, pattern matches and multi-way guards.
whereandletbindings,doblocks, and list comprehensions.- Records,
derivingclauses, and data declarations. - Multiple
LANGUAGEpragmas — pulled to the top, split one-per-line, deduplicated and sorted. - Consecutive
importlines — sorted alphabetically by module name, with qualified imports grouped after unqualified ones. - Line (
--) and block ({- -}, nestable) comments, plus pragma comments ({-# ... #-}).
Does this fully replicate Fourmolu or Ormolu?
No — this is a lightweight, dependency-free tokenizer and line-based re-spacer, not a full parser built on GHC's AST. It reformats spacing, pragma order and import order within each line without reflowing code across line boundaries, so it won't wrap long expressions the way a true pretty-printer would. For a byte-for-byte match to Fourmolu/Ormolu's output, run the real tool as part of your build.
Is my source code uploaded anywhere?
No. Tokenizing and formatting run entirely in your browser; nothing is sent to a server.
Need to format a different functional or config language?
Check out the Elixir Code Formatter for Elixir source, or the Terraform Formatter for HCL configuration.