Python Formatter

Reformat Python code with PEP 8 spacing and line lengths.

Python Formatter

.py

Paste text or open a file to see the result.

What it does

Reformats Python with PEP 8 spacing, blank lines and line lengths. Useful when code is hard to read or a project expects one style. In Python indentation is part of the code, so the tool keeps the blocks exactly as they are.

About the .py format

.PY file extension

.py Python Script

Developer Files

File Type
Python Script
Developer
Python Software Foundation
MIME
text/x-script.phyton

A .PY file is a Python script with the extension .PY. Python scripts are executed on a computer using a program called Python.

Python Formatter questions

How do I use the Python Formatter?

Paste the text into the Input box or open a file, set the options, then copy or download the result.

Does renaming a file to .py change its format?

No. The extension only tells programs what to expect, and the content of the file stays the same. To change the format, convert the file. The .py page lists programs and converters for it.