Python source → PDF with IDLE-accurate syntax highlighting
6token types
100%client-side
A4 / letterpaper sizes
0server uploads
Drop any .py file and get back a PDF that looks exactly like Python IDLE — orange keywords, purple builtins, green strings, red comments, blue function names. Everything runs in your browser; your code never leaves your machine.
convert
ready — drop a .py file to start
[ ⇡ ]
click or drag & drop a .py file
max 2 MB — processed entirely in your browser
>> options
line numbers
filename header & footer
cli builder
Prefer the terminal? Fill in the fields below and copy the exact command to run — no need to memorise flags.
line numbers
filename header & footer
>> your command
npx py2pdf-idle script.py
colour reference
py2pdf uses the exact colour scheme from Python IDLE — the editor that ships with every Python installation. These colours have been the Python standard since the early 2000s.
keyword
#ff7700
def, class, if, for, return
builtin
#900090
print, len, range, self
string
#00aa00
"hello", f-strings, triple-quoted
comment
#dd0000
# this is a comment
defname
#0000ff
function / class names after def/class
number
#000000
42, 3.14, 0xFF, 0b1010
>> live example
1def greet(name: str) -> str:
2"""Return a greeting string."""# docstring
3 count = 42
4 prefix = f"Hello, {name}!"
5 numbers = [1, 2, 0xFF, 3.14]
6 result = ", ".join(str(n) for n in numbers)
7print(prefix, result)
8return prefix
9
10class Greeter:
11def __init__(self, lang='en'):
12self.lang = lang
13
14def say(self, name):
15ifself.lang == 'en':
16return greet(name)
17raise ValueError(f"Unknown lang: {self.lang}")
18
19if__name__ == '__main__':
20 g = Greeter()
21print(g.say('world'))
22
about
1
drop your file — drag a .py file onto the upload zone or click to browse
2
preview it — the tokeniser runs instantly in your browser and shows a live preview with IDLE colours
3
configure options — toggle line numbers, header/footer, and choose paper size
4
download — click "download PDF" and get a beautifully formatted file, generated entirely client-side
> privacy
Your code never leaves your machine. Tokenisation and PDF generation both run in the browser using JavaScript. No files are uploaded to any server.