FAQ
Could indentation be changed incorrectly?
It aligns to PEP8 style, but indentation is syntax in Python. Skim the block boundaries after formatting before running.
Will f-strings and comments be damaged?
No. Strings, comments and f-strings are preserved as whole tokens, so braces inside them are not parsed as code.
Is my code uploaded?
No, formatting runs entirely in your browser.
About this tool
Beautify does two things: normalise indentation to 4 spaces according to block structure, and put spaces around operators. Block structure is inferred from line-leading def, class, if/elif/else, for, while, try/except/finally and with, combined with bracket depth — which is why ragged code pasted from a PDF, a chat log or a blog comes out straight in one pass.
Continuation lines inside unclosed brackets get one extra level, so multi-line lists, dicts and function arguments line up. Tabs count as 4 spaces, which also rescues files that mix tabs and spaces.
What it deliberately leaves alone: single-line compound statements stay single-line (if x: y=1 and a=1;b=2 are not expanded); spaces inside brackets are not cleaned up (f( a , b ) comes back unchanged); triple-quoted strings spanning lines are tracked as strings and preserved. This is "put the indentation and spacing straight", not a style rewrite.
The minify direction removes only comments and blank lines — never indentation, never inline spaces, because Python uses indentation for block structure and touching it changes meaning. So "minify" here saves comments and empty lines; the output stays multi-line. It is not an interpreter either: a wrong guess (match statements, decorator chains, unusual nesting) produces no error, so glance at block boundaries before running the result.