explaingit

psf/black

Analysis updated 2026-06-20

41,489PythonAudience · developerComplexity · 1/5LicenseSetup · easy

TLDR

Black is a Python code formatter that automatically rewrites your code to one consistent style with almost no configuration, so your team stops arguing about formatting and starts shipping.

Mindmap

mindmap
  root((black))
    What it does
      Auto-formats Python
      Rewrites in place
      Checks AST safety
    How it works
      Parse to syntax tree
      Regenerate canonical
      Verify equivalence
    Integration
      Pre-commit hook
      CI pipeline
      Editor plugins
    Audience
      Python developers
      Dev teams
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Automatically format all Python files in a project before each commit so code reviews focus on logic, not style.

USE CASE 2

Add Black to a CI pipeline so any pull request with inconsistent formatting fails the build before it's merged.

USE CASE 3

Eliminate style debates in a Python team by adopting Black as the single source of formatting truth, no configuration discussions needed.

USE CASE 4

Clean up a messy legacy Python codebase by running Black across the whole repo in one pass.

What is it built with?

Python

How does it compare?

psf/blackhpcaitech/colossalaichubin/cheat.sh
Stars41,48941,37441,341
LanguagePythonPythonPython
Setup difficultyeasyhardeasy
Complexity1/55/52/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
Use freely for any purpose including commercial projects (MIT license).

In plain English

Black is the "uncompromising" Python code formatter, a tool that automatically rewrites Python source files to conform to a single, consistent style. The word "uncompromising" is the key to understanding its design philosophy: unlike older linters or formatters that offer dozens of configuration options for line length, quote style, bracket placement, and so on, Black has very few settings. It makes all the decisions for you. The problem Black solves is the endless, low-stakes debate that happens on development teams about code style. Should strings use single quotes or double quotes? Where should long function calls be split across lines? How many blank lines between methods? These questions consume surprising amounts of attention during code review without actually improving the software. Black's answer is: stop arguing, just run the formatter. Here is how it works: you run black myfile.py or point it at a directory, and Black reformats the files in place using its opinionated rules. It parses the Python source into an abstract syntax tree (a structural representation of the code), then regenerates the code from scratch in Black's canonical style, normalizing indentation, line lengths, quote style, trailing commas, and more. As a safety check, Black verifies that the reformatted code produces an equivalent AST to the original, so it cannot accidentally change what the code does. Because Black's output is deterministic, the same input always produces the same output, it eliminates formatting-related noise in diffs and code reviews. Two developers can independently edit the same file, run Black, and get identical results. You would use Black as part of any Python project's development setup, typically integrated with a pre-commit hook or CI pipeline so that all code is automatically formatted before it is committed. The stack is Python 3.10 or later, installable via pip.

Copy-paste prompts

Prompt 1
Set up Black as a pre-commit hook in my Python project so every file is auto-formatted before I can commit. Show me the .pre-commit-config.yaml.
Prompt 2
Add Black formatting checks to my GitHub Actions CI so pull requests fail if any Python file isn't Black-formatted.
Prompt 3
I have a Python project with inconsistent formatting across 50 files. Show me how to run Black on all of them at once and verify nothing broke.
Prompt 4
Configure Black in my pyproject.toml to use 100-character line length instead of the default 88.
Prompt 5
Show me the difference between running Black in check mode vs format mode and when to use each in a CI pipeline.

Frequently asked questions

What is black?

Black is a Python code formatter that automatically rewrites your code to one consistent style with almost no configuration, so your team stops arguing about formatting and starts shipping.

What language is black written in?

Mainly Python. The stack also includes Python.

What license does black use?

Use freely for any purpose including commercial projects (MIT license).

How hard is black to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is black for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub psf on gitmyhub

Verify against the repo before relying on details.