# Code Formatter

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

**Field:** Software Development  
**Category:** Editors & Tools  
**Also known as:** Formatter, Black

## Think of it like

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

## 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

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

## Example code

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

# after running black
x = [1, 2, 3]
```

Same code, same result. Only the spacing changed.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Linter](https://learn.benibix.com/term/development/linter)
- [Code Editor](https://learn.benibix.com/term/development/code-editor)
- [Syntax](https://learn.benibix.com/term/development/syntax)
- [Source Code](https://learn.benibix.com/term/development/source-code)
- [Prettier](https://learn.benibix.com/term/development/prettier)

## Told apart from

- [Linter vs Formatter](https://learn.benibix.com/compare/linter-vs-formatter): A linter reads code and warns about likely bugs. A formatter only fixes spaces and line breaks, and never what code does.

## Taught in

- [Linters and Formatters](https://learn.benibix.com/learn/development-tools/linters-and-formatters): Coding Tools, 4/13

---

Source: https://learn.benibix.com/term/development/formatter
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
