autopep8
A tool that automatically formats Python code to conform to the PEP 8 style guide
What it is and what it does
autopep8 is a command-line tool that reads Python source files and automatically rewrites them to conform to the PEP 8 style guide. It uses pycodestyle to detect formatting violations—such as incorrect indentation, missing or extraneous whitespace, and improper comment spacing—then applies fixes without altering code logic or multiline string content.
The tool operates in several modes: it can print diffs, modify files in place, process directories recursively, or read from stdin. It supports aggressive modes for non-whitespace changes, selective error fixing via include/exclude lists, and configuration via local or global pep8 config files. It's designed for developers who want automated style compliance without manual formatting work.
Use it for:
- Automatically reformat a codebase to meet PEP 8 standards before committing or deploying
- Integrate into CI/CD pipelines to enforce consistent style across pull requests
- Fix formatting violations reported by linters without manually editing each line
- Recursively clean up style issues across an entire project directory
- Apply selective fixes to only certain error categories while leaving others untouched
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
autopep8 automatically reformats Python code to comply with PEP 8 style rules, using pycodestyle to identify formatting violations and applying fixes across indentation, whitespace, and comment spacing.
Yes. autopep8 is a stable, actively maintained tool with no known vulnerabilities, low install friction, and permissive licensing. It solves a concrete problem—automated PEP 8 compliance—and is suitable for any Python project that needs style enforcement. Install it if you want to automate formatting rather than enforce it via linting alone.
Install
autopep8 on PyPI
pip
pip install autopep8uv
uv add autopep8poetry
poetry add autopep8Installing autopep8
Before you install
Low install friction with a pure-Python wheel and only two runtime dependencies (pycodestyle and tomli). The project is actively maintained with recent commits and has been in production use since 2011, supporting current Python versions (3.9+).
License in practice
Licensed under MIT (permissive), meaning you can use, modify, and distribute autopep8 freely with minimal restrictions—suitable for both open-source and proprietary projects.
Quickstart
pip install autopep8
autopep8 --in-place --aggressive myfile.py
Verify before relying
- Whether the tool can be integrated as a library (not just CLI) and what the programmatic API surface looks like
- Performance characteristics when processing large codebases or running recursively across many files
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — pycodestyle, tomli |
| Maintenance | actively maintained — 577 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,612,203/month — #1,443 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: autopep8-2.3.2-py2.py3-none-any.whl
Keywords: automation, pep8, format, pycodestyle
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pep8Checks Python code against PEP 8 style…
permissive · top 5,000 on PyPI
pycodestylepycodestyle checks Python code against PEP 8…
permissive · top 1,000 on PyPI
sort-linesAlphabetizes lines in files based on…
permissive · top 15,000 on PyPI
yapfYAPF automatically reformats Python code to…
permissive · top 5,000 on PyPI
paragraphsProvides a single function that joins…
permissive · top 15,000 on PyPI
bashatebashate is a style checker for bash scripts…
permissive · top 15,000 on PyPI
autoflakeautoflake removes unused imports and unused…
permissive · top 5,000 on PyPI
doc8doc8 is a style checker for reStructuredText…
permissive · top 5,000 on PyPI
flake8-noqaA flake8 plugin that validates the formatting…
copyleft · top 5,000 on PyPI
codefindCodefind locates code objects by filename and…
unclear · top 15,000 on PyPI