flynt
CLI tool to convert a python project's %-formatted strings to f-strings.
What it is and what it does
Flynt is a command-line refactoring tool that scans Python source files and automatically rewrites string formatting expressions into f-strings. It processes %-style formatting (e.g., `'%s' % var`) and .format() calls (e.g., `'{}'.format(var)`) into their f-string equivalents (e.g., `f'{var}'`), modernizing code to use Python 3.6+ syntax. The tool can operate on single files or recursively traverse directories, skipping common non-source folders like venv and site-packages.
Flynt is designed as a safe, automated refactoring pass for existing projects. It offers dry-run and linting modes, configuration via pyproject.toml, and integration with pre-commit hooks. The tool depends only on tomli for configuration parsing and uses Python's built-in ast module for code transformation. While it handles the vast majority of formatting conversions, the fact sheet documents a known edge case where single-element tuples format differently under f-strings, and some format specifiers (like %d with floats) may raise different exceptions than before.
Use it for:
- Modernize a legacy Python codebase by converting all string formatting to f-strings in a single automated pass.
- Enforce f-string usage in a project via a pre-commit hook to ensure consistent formatting style across all commits.
- Dry-run conversion on a project to review what changes would be made before applying them to version control.
- Integrate into a CI/CD pipeline as a linting check to fail builds if non-f-string formatting is detected.
- Convert string concatenations or static joins to f-strings when using Python 3.9+ with the --transform-concats or --transform-joins flags.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flynt is a command-line tool that automatically converts Python string formatting from %-style and .format() syntax to f-strings, modernizing codebases to Python 3.6+ syntax.
Yes. Flynt is a low-friction, actively maintained tool with no security vulnerabilities, permissive licensing, and a clear, single purpose: automating string formatting modernization. It's well-suited for teams wanting to standardize on f-strings or for one-time codebase refactoring. The documented edge cases (tuple formatting, format specifier differences) are manageable with adequate test coverage and are not blockers for most projects.
Install
flynt on PyPI
pip
pip install flyntuv
uv add flyntpoetry
poetry add flyntInstalling flynt
Before you install
Installation is straightforward with low friction—a single pure-Python wheel with one lightweight dependency (tomli). The project is actively maintained with recent commits and has been stable since its initial release in 2019.
License in practice
Flynt is released under the MIT license, a permissive open-source license that allows free use, modification, and distribution with minimal restrictions—suitable for both commercial and personal projects.
Quickstart
pip install flynt
# Convert all .py files in a directory recursively
flynt /path/to/project
# Or convert a single file
flynt script.py
# Dry-run to see changes without modifying
flynt --dry-run /path/to/project
Requires Python 3.9 or later. Files will be modified in-place; version control is strongly recommended before running.
Verify before relying
- Whether the tool correctly handles all edge cases in tuple formatting (the fact sheet documents one known case where behavior differs).
- Performance characteristics on very large codebases or projects with thousands of files.
- Maturity and reliability of the Jupyter notebook transformation feature, which is noted as alpha.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — tomli |
| Maintenance | actively maintained — 381 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 134,527/month — #11,472 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flynt-1.0.6-py3-none-any.whl
Keywords: strings, utility
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
flake8-use-fstringA flake8 plugin that detects and flags…
permissive · top 15,000 on PyPI
future-fstringsEnables f-string syntax in Python versions…
permissive · top 15,000 on PyPI
flake8-pep3101A flake8 plugin that detects and flags…
copyleft · top 15,000 on PyPI
fissixfissix is a backport of Python's lib2to3…
permissive · top 15,000 on PyPI
docoptParses command-line arguments based on a help…
permissive · top 5,000 on PyPI
docstrfmtAutomatically formats reStructuredText in files…
permissive · top 15,000 on PyPI
darkerDarker reformats Python source code in Git…
permissive · top 15,000 on PyPI
shandy-sqlfmtA command-line SQL formatter that automatically…
permissive · top 5,000 on PyPI
flake8-literalA flake8 plugin that enforces consistent…
copyleft · top 15,000 on PyPI
mdformat-blackA plugin for mdformat that automatically…
permissive · top 15,000 on PyPI