不喜欢广告? 无广告 今天

Elixir Code Formatter

开发人员文本
广告 移除?

或者
Used to flag overly long lines (mix format default is 98).
广告 移除?

指导

Elixir Code Formatter

Elixir Code Formatter

Paste your Elixir source code and get clean, mix format-style output instantly in your browser. Standardize indentation, normalize spacing around operators, sort alias / import / require / use blocks, and surface syntax problems before they reach iex. Everything runs client-side, so your code never leaves your machine.

如何使用

  1. Paste Elixir code into the input box, drop a .ex / .exs file onto the uploader, or click 尝试一个示例.
  2. 可选地调整 max line length (default 98, matching mix format) so over-long lines get flagged.
  3. 切换 Sort alias / import / require / use if you want consecutive blocks alphabetized.
  4. The formatted output appears in real time. Copy it, or download it as formatted.ex.

特征

  • mix format-style indentation – 2-space indent, tracks do / fnendelse / rescue / catch / after re-dents.
  • 操作符间距 – standardizes =, ==, |>, ->, <-, ::, ++, <>, and friends.
  • Map & struct prefixes – tightens %{...}%MyStruct{...} without breaking modulo arithmetic.
  • Bitstring brackets – preserves <<...>> without adding stray spaces.
  • Sort alias / import / require / use – alphabetize consecutive blocks (keyword + indent must match).
  • 语法验证 – catches unbalanced parens, brackets, braces, bitstrings, do/end mismatches, and unterminated heredocs.
  • Line-length warning – flags lines exceeding your configured maximum (40–200).
  • Heredocs, sigils, charlists – string interiors and ~r/.../, ~s(...), ~S"""...""" are preserved verbatim.
  • Drag-and-drop upload – format any .ex / .exs file directly.
  • 100% 客户端 – nothing is uploaded; works offline once the page loads.

常问问题

  1. What is mix format and why does Elixir need one?

    mix format is the official Elixir code formatter, introduced in Elixir 1.6. It parses source into an AST and pretty-prints it back using a single, deterministic style. Because every Elixir project shares the same conventions, teams stop arguing about whitespace, code reviews focus on logic instead of layout, and diffs stay clean across editors and operating systems.

  2. What does the pipe operator |> actually do?

    The pipe operator passes the value on its left as the first argument to the function on its right. So data |> transform() |> save() is equivalent to save(transform(data)). Pipes read top-to-bottom in the order operations happen, which is why idiomatic Elixir places each |> on its own line indented two spaces from the value being piped.

  3. Why do Elixir variables look immutable even when they are reassigned?

    Elixir variables are rebindings, not mutations. x = 1 followed by x = 2 creates a new binding of the name x; the original value 1 still exists in memory until garbage-collected. Inside pattern matches, = is the match operator, not assignment, which is why {:ok, value} = result destructures and binds simultaneously.

  4. What is the difference between a do block and the do: keyword shorthand?

    def foo do ... end is the multi-line block form, where the body can contain any number of expressions. def foo, do: expr is the keyword-list shorthand for a single-expression body and is parsed as a 2-tuple {:do, expr} in a keyword list. Both produce identical bytecode; the shorthand is preferred for one-liners and the block form for multi-statement bodies.

  5. Why are charlists and binaries different in Elixir?

    A double-quoted string is a UTF-8 binary — a sequence of bytes. A single-quoted charlist is a linked list of Unicode codepoints, inherited from Erlang where strings are traditionally lists of integers. Most Elixir APIs (Phoenix, Ecto, Plug) work with binaries; charlists mainly appear at Erlang interop boundaries (:inets, :gen_tcp, etc.) where the underlying library expects lists.

想要享受无广告的体验吗? 立即无广告

安装我们的扩展

将 IO 工具添加到您最喜欢的浏览器,以便即时访问和更快地搜索

添加 Chrome 扩展程序 添加 边缘延伸 添加 Firefox 扩展 添加 Opera 扩展

记分板已到达!

记分板 是一种有趣的跟踪您游戏的方式,所有数据都存储在您的浏览器中。更多功能即将推出!

广告 移除?
广告 移除?
广告 移除?

新闻角 包含技术亮点

参与其中

帮助我们继续提供有价值的免费工具

给我买杯咖啡
广告 移除?