Elixir Code Formatter
Memandu
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.
Cara Penggunaan
- Paste Elixir code into the input box, drop a
.ex/.exsfile onto the uploader, or click Coba contoh ini. - Secara opsional sesuaikan max line length (default 98, matching
mix format) so over-long lines get flagged. - Beralih Sort alias / import / require / use if you want consecutive blocks alphabetized.
- The formatted output appears in real time. Copy it, or download it as
formatted.ex.
Fitur
- mix format-style indentation – 2-space indent, tracks
do/fn↔enddanelse/rescue/catch/afterre-dents. - Penempatan operator – standardizes
=,==,|>,->,<-,::,++,<>, and friends. - Map & struct prefixes – tightens
%{...}dan%MyStruct{...}without breaking modulo arithmetic. - Bitstring brackets – preserves
<<...>>without adding stray spaces. - Sort alias / import / require / use – alphabetize consecutive blocks (keyword + indent must match).
- Validasi sintaks – catches unbalanced parens, brackets, braces, bitstrings,
do/endmismatches, 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/.exsfile directly. - 100% sisi klien – nothing is uploaded; works offline once the page loads.
Tanya Jawab Umum
-
What is
mix formatand why does Elixir need one?mix formatis 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. -
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 tosave(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. -
Why do Elixir variables look immutable even when they are reassigned?
Elixir variables are rebindings, not mutations.
x = 1followed byx = 2creates a new binding of the namex; the original value1still exists in memory until garbage-collected. Inside pattern matches,=is the match operator, not assignment, which is why{:ok, value} = resultdestructures and binds simultaneously. -
What is the difference between a
doblock and thedo:keyword shorthand?def foo do ... endis the multi-line block form, where the body can contain any number of expressions.def foo, do: expris 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. -
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.
Instal Ekstensi Kami
Tambahkan alat IO ke browser favorit Anda untuk akses instan dan pencarian lebih cepat
恵 Papan Skor Telah Tiba!
Papan Skor adalah cara yang menyenangkan untuk melacak permainan Anda, semua data disimpan di browser Anda. Lebih banyak fitur akan segera hadir!
Alat Wajib Coba
Lihat semua Pendatang baru
Lihat semuaMemperbarui: Kita alat terbaru was added on Mei 23, 2026
