## free style checker · runs in your browser

Check your Python code against PEP 8

Paste a snippet or open a .py file to see pycodestyle-style warnings for layout, whitespace, blank lines, imports and common comparisons. Nothing is uploaded. Then read why each rule exists: Four Spaces is an independent publication about Python style and readable code.

style check · pycodestyle subset

Runs entirely in your browser: your code is not uploaded, stored or logged.

What this checker covers

It is a JavaScript port of part of pycodestyle, the reference PEP 8 checker, and uses the same codes and messages. Before publication it was compared with pycodestyle 2.15 on more than 900 real Python files and gave the same results for the codes below in all but four of more than 27,000 warnings; three of the differences were inside f-string expressions, which it does not check.

  • E1, W191: indentation not a multiple of four, unexpected or over-indentation, tabs, tabs mixed with spaces (E101).
  • E2: whitespace inside brackets, before commas and colons, around operators (E225, E231), keyword arguments (E251, E252), inline and block comments.
  • E3: blank lines around functions, classes and methods (E301 to E306).
  • E4, E501: one import per line, imports at the top; line length.
  • E7: compound statements, == None (E711), == True (E712), not x in y, type comparisons, bare except:, assigned lambdas, ambiguous names.
  • W2, W3, W605: trailing whitespace, missing final newline, blank lines at the end, invalid escape sequences.

What it does not check

Continuation-line alignment (E12x), line breaks around operators (W503, W504), naming conventions, docstrings, unused imports and other errors, and type errors. Like pycodestyle, it skips the checks PEP 8 does not require by default, such as E226.

For whole projects, run the real tools: how to check Python style locally with pycodestyle, flake8 or ruff. Each code is explained in our pycodestyle error code reference.

PEP 8, section by section

All PEP 8 guides

The official style guide explained rule by rule, with the warnings each rule produces.

Linters & formatters

All tool guides

pycodestyle, flake8, pylint, black, ruff and pre-commit, described from their documentation.

A mover in a blue T-shirt tapes up a tall cardboard box in an apartment, with more boxes on the floor # practical guide

Relocating as a software developer: a checklist for your first months in a new city

Paperwork and the right to work, a home with a good connection and a sane commute, the first week's admin, and onboarding into a new codebase while you settle into a new city.

Read the checklist

Docstrings, comments & types

All documentation guides

Documentation that lives in the code: PEP 257, useful comments and type hints.

Readable code in practice

All practice guides

What the linter cannot see: readability, code review and bringing old code in line.

More from PEP 8

All PEP 8 guides

Naming, imports and the programming recommendations at the end of the guide.