skillfed

yapf

A formatter for Python code

yapf v0.43.0 9.2M downloads/30d#1,557 on PyPI13,980
Permissive license Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) Active released

What it is and what it does

YAPF is a Python code formatter that automatically rewrites code to match a configured style, based on the clang-format algorithm. Rather than enforcing rules line-by-line, it analyzes the entire code structure and calculates the best formatting that conforms to your chosen style. It supports predefined styles (pep8, google, yapf, facebook) and custom configurations via .style.yapf, setup.cfg, or pyproject.toml files.

You can use YAPF as a command-line tool to format files in place, print diffs, or run recursively over directories, or as a Python library by importing FormatCode and FormatFile from yapf.yapflib.yapf_api. It requires Python 3.7 or later and integrates with many editors via community plugins.

Use it for:

  • Enforce consistent code style across a team or project without manual review of formatting details.
  • Integrate into a CI/CD pipeline to verify that code has been formatted correctly before merging.
  • Reformat legacy Python code to a modern style guide in bulk.
  • Use as a library in an IDE or editor plugin to format code on save or on demand.
  • Configure custom formatting rules for a project and apply them consistently to all Python files.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

YAPF automatically reformats Python code to conform to a specified style guide, calculating the best formatting that matches your chosen style.

Yes. YAPF is actively maintained with low install friction, permissive licensing, and no known vulnerabilities. Install it if you want automatic, style-guide-compliant code formatting in your workflow—either as a standalone tool or integrated into your development environment.

Install

yapf on PyPI

pip

pip install yapf

uv

uv add yapf

poetry

poetry add yapf

Installing yapf

Before you install

Low install friction with only two runtime dependencies (platformdirs and tomli). Actively maintained with recent commits and a large repository following (13980 stars).

License in practice

Apache License 2.0 is permissive and allows commercial use, modification, and distribution with minimal restrictions—you can use YAPF in proprietary projects as long as you include a copy of the license and note any changes you make.

Quickstart

pip install yapf

from yapf.yapflib.yapf_api import FormatCode

formatted_code, changed = FormatCode("f ( a = 1, b = 2 )")
print(formatted_code)

Requires Python 3.7 or later (supports 3.7, 3.8, 3.9, 3.10, 3.11)

Verify before relying

  • Whether YAPF's formatting output is deterministic across different Python versions or systems.
  • Performance characteristics when formatting very large files or entire codebases.
  • How well YAPF integrates with modern Python tooling in the same workflow.

Package facts

License Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — platformdirs, tomli
Maintenance actively maintained — 638 days since the last release
Last repo commit
First released
Downloads 9,155,087/month — #1,557 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: yapf-0.43.0-py3-none-any.whl

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

python code formatterautomatic code formattingstyle guide enforcementpep8 formatterpython code beautifierformat python filescode style automation
code-formatterstyle-enforcementcli-tool

More Python Modules packages