Home » Developer Tools » Python Minifier
Paste Python and get a smaller version in seconds, with indentation kept exactly as Python needs it.
Your code never leaves your browser. Everything runs locally on your device.
Python is different from other languages: indentation is part of the syntax, so a careless minifier that joins lines or strips spaces will break your code. The Python Minifier is built around that rule and never touches indentation.
Instead it removes only what Python does not need to run: comments, docstrings, and blank lines, plus trailing whitespace. The saving is modest, but the output is still valid Python you can run. Everything happens in your browser, so your code is never uploaded to a server.
Yes, it is completely free with no sign up and no limits. You can minify as much Python as you like, as often as you like.
Yes. The minifier never changes indentation or joins lines, so blocks and nested code keep their meaning. Only comments, docstrings, and blank lines are removed.
Python uses indentation and line breaks as syntax, so lines cannot be joined with semicolons the way JavaScript lines can. The saving comes from comments, docstrings, and blank lines only.
No. Text inside strings is preserved exactly, including a hash sign inside a string, and triple quoted string content is left untouched.
Yes. Turn off the docstring option and only comments and blank lines will be removed.
No. All minifying happens in your browser on your own device, so your code never leaves your computer.
If your Python needs tidying up instead of shrinking, try the Python formatter to normalize its indentation and spacing.