skillfed

autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide

autopep8 v2.3.2 10.6M downloads/30d#1,443 on PyPI4,659
Permissive license Active released

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 autopep8

uv

uv add autopep8

poetry

poetry add autopep8

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

pep 8 code formatterpython style guide auto-fixpycodestyle automatic fixerpython code reformatterpep8 compliance toolwhitespace and indentation fixerpython formatting automation
code-formatterpep8style-automation

More Python Modules packages