DEVELOPER TOOL

Python Formatter

Clean up Python whitespace, tabs, and blank lines without touching logic.

About this tool

Clean up messy Python source: convert tabs to spaces, strip trailing whitespace, collapse runs of blank lines, and normalize line endings — the whitespace cleanup a linter would flag, without touching your code's logic or structure.

This does not re-indent or reflow your code the way a full formatter like Black would. Python's indentation is semantically meaningful, so guessing new indentation from scratch risks silently changing what your code does — this tool only ever normalizes whitespace that's already consistent, never restructures it.

Frequently asked questions

Why doesn't this re-indent my code like Black or autopep8?
Those tools parse Python into a syntax tree to safely rewrite indentation and line breaks. A browser-side regex/text tool can't safely do that for an indentation-sensitive language — get those tools via pip for full reformatting; this one focuses on the whitespace cleanup that's always safe.
Will "Convert tabs to spaces" break my indentation?
No — each tab character is replaced with 4 spaces, preserving the relative indentation depth exactly, which is the standard PEP 8 convention.
What counts as an "extra" blank line?
Runs of 3 or more consecutive blank lines are collapsed down to 2 (the PEP 8 convention for separating top-level definitions); single or double blank lines are left untouched.