██████╗ ██╗   ██╗██████╗ ██████╗ ██████╗ ███████╗
██╔══██╗╚██╗ ██╔╝╚════██╗██╔══██╗██╔══██╗██╔════╝
██████╔╝ ╚████╔╝  █████╔╝██████╔╝██║  ██║█████╗  
██╔═══╝   ╚██╔╝  ██╔═══╝ ██╔═══╝ ██║  ██║██╔══╝  
██║        ██║   ███████╗██║     ██████╔╝██║     
╚═╝        ╚═╝   ╚══════╝╚═╝     ╚═════╝ ╚═╝
py2pdf
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.

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

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
def, class, if, for, return
builtin
print, len, range, self
string
"hello", f-strings, triple-quoted
comment
# this is a comment
defname
function / class names after def/class
number
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)
7 print(prefix, result)
8 return prefix
9 
10class Greeter:
11 def __init__(self, lang='en'):
12 self.lang = lang
13
14 def say(self, name):
15 if self.lang == 'en':
16 return greet(name)
17 raise ValueError(f"Unknown lang: {self.lang}")
18 
19if __name__ == '__main__':
20 g = Greeter()
21 print(g.say('world'))
22 
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.

> tech stack
Next.js 14jsPDFJetBrains MonoVercel Analyticscustom tokeniser
> limitations
  • Multi-line strings spanning more than one page may not wrap perfectly
  • Very long lines are clipped at the right margin
  • Max file size 2 MB (roughly 40,000 lines)
  • PDF uses Courier — matching IDLE's default monospace font
made by Kayan Shahview source