Outline
Convert Python code to syntax-highlighted HTML
This converter turns a .py file or pasted Python code into clean, color-highlighted HTML you can put on a website, in a blog post, in documentation, in an email, or in a Word or Google Docs file. It reads your code with a real Python tokenizer, so f-strings, decorators, docstrings, type hints, and match statements are colored the way an editor would color them, not guessed at with a few patterns.
Your code never leaves your browser. There's no upload, so it's safe for private scripts and work projects.
How to use it
- Paste your Python code, open a
.pyfile, or drop a file onto the tool. Jupyter notebooks (.ipynb) work too. - Pick a color theme and font size. The preview updates as you type.
- Choose an output type (see below), and turn line numbers, wrapping, and the file name bar on or off.
- List any lines you want to call out in Highlight lines, like
4, 10-12. - Copy the HTML, copy the formatted code for a document, download a standalone page, or print it to PDF.
Which HTML output should I use?
| Output | What you get | Best for |
|---|---|---|
| Inline styles | Every color is written directly on each element. No stylesheet is needed, so it looks right wherever you paste it. | WordPress Custom HTML blocks, email newsletters, forums, CMS editors, Notion embeds |
| CSS classes + stylesheet | Short class names like py-k plus one small <style> block. The markup is much smaller, and you can restyle it later. | Your own site or docs, where many code samples share one stylesheet |
| Full HTML page | A complete, standalone .html document with a title and styles. | Sharing a script as a file, archiving, code reviews, printing |
Copy formatted puts the highlighted code on your clipboard as rich text. Paste it into Microsoft Word, Google Docs, Outlook, or Gmail and the colors come with it, no HTML editing needed.
What gets highlighted
- Keywords such as
def,class,async,await, andyield, plus the soft keywordsmatchandcasewhen they start a statement. - Strings of every kind: single, double, triple-quoted, raw, bytes, and f-strings. The expressions inside f-string braces are highlighted as code, and escape sequences like
\nstand out. - Docstrings get their own softer style, so documentation reads differently from string data.
- Definitions: function and class names where they're defined, decorators, and function calls.
- Built-ins like
print,len, andisinstance, built-in exceptions,selfandcls, and dunder names like__init__. - Numbers in every form Python accepts:
1_000_000,0xFF,0b1010,1.5e-3, and complex numbers like2j.
Adding highlighted Python to WordPress
Choose "Inline styles," copy the HTML, and paste it into a Custom HTML block in the block editor. Because every color is built in, the code looks the same whatever theme your site uses, and you don't need a syntax highlighting plugin. The line numbers can't be selected, so readers who copy the code get only the code.
Jupyter notebooks
Open an .ipynb file and the tool pulls out every code cell in order, marking each one with an In [n] comment, like jupyter nbconvert --to script does. Markdown cells are kept as comments, so the explanation stays with the code.
Printing and PDF
Print / PDF opens your browser's print dialog with just the code, keeping the theme colors. Choose "Save as PDF" as the printer to create a PDF. For long lines on paper, turn on Wrap long lines first so nothing gets cut off at the page edge.
Frequently asked questions
Is my Python code uploaded anywhere?
No. Reading the file, highlighting, and building the HTML all happen in your browser. Nothing is sent to FlipperFile or anyone else.
Does the tool run my code?
No. It only reads the text to decide how to color it. Nothing is executed, so it's safe to open any script.
How is this different from Pygments?
Pygments is the Python library behind many highlighters, used from the command line with pygmentize -f html. This tool gives similar results without installing anything, adds a live preview and inline-style output, and lets you copy rich text straight into documents.
Will the code still be copyable from my web page?
Yes. The code is real text inside a <pre> element, not an image. Line numbers are marked so they aren't selected, so readers copy only the code.
Can it handle large files?
Files up to several thousand lines convert in well under a second. The preview shows the first 4,000 lines to stay responsive, while the HTML output always includes the whole file.
What about other languages?
This converter is tuned specifically for Python, including recent syntax like the walrus operator, match statements, and nested f-string quotes. Other languages would highlight incorrectly.

