Skip to content
BENIBIX Learn

Code Formatter

Development🛠️ Editors & ToolsCode Quality Tools

Also known as Formatter, Black

A tool that fixes the layout of code, like spaces and line breaks, to one style.

Think of it like

Think of it like a robot that folds the laundry. Every shirt comes out folded the same way.

Example

Jack's file has messy spacing. One run of Black, and it matches the rest of the team's code.

Why it matters

When all code looks the same, changes are easier to review. Only real changes show up, not spacing.

Definition

A code formatter rewrites your code so its layout follows one fixed style. It sets the spaces, line breaks, quotes and indents. It never changes what the code does, only how it looks. Prettier for JavaScript and Black for Python are well known. Teams run it on every save, so nobody argues about spacing again.

Example code

python
# before
x=[1,2,
  3]

# after running black
x = [1, 2, 3]
Same code, same result. Only the spacing changed.

Common mistake

Mixing it up with a linter. This one fixes the look; a linter warns about bugs.

Key takeaways

  1. 1
    Layout only. What the code does stays the same.
  2. 2
    One style. Everyone's code ends up looking alike.
  3. 3
    Run it often. Many editors format on every save.

Compare

Learn it properly