A Python utility to sort imports alphabetically and automatically separate them into sections.
isort is a Python utility and library that automatically sorts import statements alphabetically and separates them into sections like standard library, third-party, and local imports. It solves the problem of messy, inconsistent import organization in Python codebases, ensuring readability and adherence to style guides. It can be used via command line, as a Python library, or integrated into editors and CI workflows.
Python developers and teams who want to maintain clean, consistent import styles in their codebases, especially those working on large projects or with strict coding standards.
Developers choose isort because it automates a tedious task with high configurability, integrates seamlessly into existing workflows (e.g., pre-commit, editors), and supports complex formatting needs like balanced multi-line imports. It’s widely adopted and trusted in the Python community.
A Python utility / library to sort imports.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
isort offers 12 multi-line output modes and customizable sections, allowing fine-grained control over import organization as detailed in the configuration guides.
With plugins for popular IDEs like VS Code and pre-commit hooks, it automatically sorts imports on save or during commits, integrating into existing workflows.
The balanced_wrapping option dynamically adjusts import length for cleaner multi-line statements, improving readability without manual tweaks.
The --check-only option verifies import sorting without changes, ideal for CI pipelines to enforce consistency, as shown in the pre-commit examples.
With numerous options like custom sections and 12 output modes, initial setup can be overwhelming for teams with specific style requirements.
The README includes a separate compatibility guide for Black, indicating extra configuration is needed to avoid conflicts with other formatters.
Atomic mode is disabled by default as it prevents running against code from different Python versions, reducing out-of-the-box reliability for mixed-version projects.