What this Python editor does
This is a lightweight, browser-based editor for writing and tidying Python code without installing anything. It gives you syntax highlighting, find and replace, word wrap, a light or dark theme, a fullscreen mode, and a one-click download as a .py file. It's useful for jotting down a script on a machine without an IDE, cleaning up a snippet before pasting it into documentation, or sharing a file.
It doesn't run your code. There's no Python interpreter in the page, so output, errors and print() statements won't appear. To run Python, see "Running your code" below.
Editor features
| Feature | What it does |
|---|---|
| Syntax highlighting | Colors keywords, strings, numbers, comments and decorators so structure is easy to scan |
| Find and replace | Search the file and replace one or all matches |
| Word wrap | Wraps long lines instead of scrolling sideways |
| Theme | Switches between light and dark color schemes |
| Fullscreen | Gives the editor the whole screen for longer files |
| Copy / Download | Copies the code to the clipboard or saves it as main.py |
A quick example to try
Paste this into the editor to see the highlighting at work. It uses several modern Python features, including type hints, an f-string and a dataclass:
from dataclasses import dataclass
@dataclass
class Item:
name: str
price: float
quantity: int = 1
def total(self) -> float:
return self.price * self.quantity
cart = [Item("Notebook", 3.50, 2), Item("Pen", 1.25)]
grand_total = sum(item.total() for item in cart)
print(f"Total: ${grand_total:.2f}") # Total: $8.25
Running your code
When you're ready to execute what you've written:
- Download the file with the Download button. It saves as
main.py. - Install Python if you don't have it. The official installers are at python.org.
- Open a terminal in the folder where you saved the file and run
python main.py(on macOS and Linux this may bepython3 main.py).
New to Python? The free Python course starts with your first Python program, and the Python cheat sheet is a one-page reference for syntax.
Python style basics
Python uses indentation to define blocks, so consistent formatting matters more than in most languages. The official style guide, PEP 8, recommends:
- 4 spaces per indentation level, never mixing tabs and spaces,
snake_casefor functions and variables,PascalCasefor classes,- two blank lines between top-level functions and classes,
- lines of at most 79 characters (many teams relax this to 88 or 100).
Other online editors
The same editor is available for JavaScript, JSON (with one-click formatting), and other languages from the code editors page.
Last updated