Skip to main content

A Python import organizer

Project description

Imporganizer organizes any imports of Python files found in the start of the file, putting them in alphabetic order. Comments or docstrings in the first lines are not supported yet. This feature is planned.


Your imports need to be formatted in these rules:

  • They must be at the start of the file (blank lines before the first import will be removed).
  • They must use forward-slash to define multi-line imports.
  • They must be separated from the rest of the file (Python code) by 2 empty lines.


from django.models import Model, \


from django.models import (Model,


Install using pip:

$ pip install imporganizer

Use with the command line (main usage):

$ imporganizer --third-party=package1,package2 --homemade=package3,package4

Update the standard packages list with:

$ imporganizer --update-builtin

You can’t update the builtin list and organize a file with a single command, but this is a feature in our roadmap.


They will be categorized by:

  • Standard: all packages included with the default distribution of Python.
  • Third party: all packages not standard and not internal to the project.
  • Homemade: dependencies, packages and modules internal to the project.

To be able to categorize your packages this way, you must inform which ones are third party and which ones are internal to the project. You do this by the command line:

imporganizer --third-party=package1,package2 --homemade=package3,package4

For an input like this:

from django.forms import Form, \
from textwrap import dedent

from django.db.models import Model
import sys
import os
import internal

import another_internal


The output will be:

import os
import sys
from textwrap import dedent

from django.db.models import Model
from django.forms import CharField, \

import another_internal
import internal


It will assume a maximum line length of 79 characters.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for imporganizer, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size imporganizer-1.1.1.tar.gz (6.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page