Skip to main content

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

Formatted Haskell
 
Validation
Issue
No data yet
Was this helpful?

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

  1. Paste your Haskell (.hs) source.
  2. Choose 2 spaces (Fourmolu's default) or 4 spaces (Ormolu's default) for indentation.
  3. Set the max line length used to flag overly long lines in the validation report (100 is Fourmolu/Ormolu's default).
  4. Toggle sort imports, sort/dedupe LANGUAGE pragmas, and collapse blank lines as needed.
  5. 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.
  • where and let bindings, do blocks, and list comprehensions.
  • Records, deriving clauses, and data declarations.
  • Multiple LANGUAGE pragmas — pulled to the top, split one-per-line, deduplicated and sorted.
  • Consecutive import lines — 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.

haskellformatterfourmoluormoludeveloper

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.