Skip to main content

Elixir Code Formatter

Format and beautify Elixir source code — operator/comma spacing, do/fn/end block-depth indentation, blank-line normalization around def/defmodule, and optional alphabetical sorting of alias/import/require/use groups, matching mix format conventions. Includes basic bracket and block-balance validation. Runs entirely in your browser.

Input

Drop a file or browse
One file · text
Or

Used to flag overly long lines (mix format default is 98).

Output

Validation
Issue
No data yet
Formatted Elixir Code
 
Was this helpful?

Guides

Paste unformatted Elixir source and get back code with consistent operator/comma spacing, do/fn/end block-depth indentation, and normalized blank lines — matching mix format conventions as closely as a browser-based formatter can. Strings, charlists, sigils (~r, ~D, …), heredocs, and comments are tokenized and left untouched; only the surrounding code gets reformatted. A quick validation pass flags unbalanced brackets and unmatched do/fn/end blocks. Everything runs locally in your browser.

How to use it

  1. Paste your Elixir source, or upload a .ex/.exs file.
  2. Set Max Line Length to flag overly long lines (the mix format default is 98).
  3. Turn on Sort & Group alias / import / require / use blocks to alphabetize each consecutive run of alias/import/require/use statements by module path — leave it off to keep your original order.
  4. Check the Validation panel for any syntax issues, then copy or download the formatted result.

What it formats

  • Spacing around binary operators (+ - * / == != <= >= && || <> .. |> -> <-) and unary -/!/^/&, which stay tight against their operand.
  • Commas, semicolons, and the key: shorthand used in keyword lists and do:/else: blocks.
  • %{...} maps and %MyStruct{...} struct literals, kept tight against the following brace.
  • Indentation by do/fnend block depth and bracket depth, with else/rescue/catch/after dedented back to their block's own level.
  • Blank-line normalization: collapses runs of blank lines to one, removes a stray blank right before end/)/]/}, and inserts one before a def/defmodule/defprotocol/… declaration that follows other code (but not right after a block opener, or after its own @doc/@moduledoc/@spec).

Does it validate the code semantically?

No — this checks structure only: unbalanced ()[]{}, an unmatched do/fn without its end (or vice versa), and an unterminated heredoc. It won't catch an undefined function or a pattern-match that can never succeed. For real validation, use mix compile or mix format --check-formatted.

Is my code uploaded anywhere?

No. Tokenizing, spacing, and re-indenting all run locally in your browser; your Elixir source is never sent to a server.

Need to format a different language?

Use the Zig Language Formatter or the Lua Code Formatter for other hand-rolled, browser-side formatters.

elixircode formatterbeautifymix formatindentpretty print

Love the tools? Lose the ads.

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