Editor

Embed Runnable Python Code in Any Website

One iframe tag turns your code sample into a live editor on your page. Free, with no account and no API key.

Create Your Embed

Try:
Loading editor…
Theme
px(sized to your code automatically)
Copy this into your page
Using Notion or another embed-by-URL block? Copy the link instead:
Live preview (press Run in it, it works)

Make Every Python Block on Your Site Runnable

Writing a blog, a course or documentation with many code samples? Add one line to your site's template instead of an embed per example:

<script src="https://pythoncompiler.io/embed.js" defer></script>

Every Python code block on the page gets a small Run button. When a reader presses it, the block turns into a runnable editor with the same code, and it runs straight away. Nothing loads until then, so your pages stay fast, and your code stays in your own HTML for search engines.

  • It finds blocks marked as Python by common highlighters (language-python, lang-python, highlight-python), plus any element you mark with data-pcio.
  • data-pcio-run="auto" on a block shows the editor at once, without the button.
  • On the script tag, data-theme="light" or "dark" fixes the theme (it follows the reader's setting otherwise), and data-selector picks your own blocks.

For a single link instead, such as in a GitHub README, use the Run badge: [![Run in pythoncompiler.io](https://pythoncompiler.io/badge-run.svg)](https://pythoncompiler.io/?code=...), with the link from Share in the editor.

Put It Where You Publish

WordPress
Add a Custom HTML block to your post and paste the iframe tag into it.
Ghost
Add an HTML card and paste the iframe tag.
Notion
Paste the widget link (use "Copy link" in the generator, not the tag) and choose Create embed.
Moodle, Canvas & other LMS
Open the HTML source view of the content editor and paste the tag. If it does not render, your school admin may have iframes restricted.
Hugo, Jekyll, Astro, plain HTML
Paste the tag straight into your content. It is just an iframe, nothing to configure.
Medium & Substack
These two do not accept custom iframes at all. Share a link to the full editor with your code preloaded instead: the Share button in the editor copies one.

How It Works

  1. Paste your code into the generator above. Working on something in the editor? Click Embed there and the tag is already on your clipboard.
  2. Add the tag to your page using whichever method your platform needs. The section above covers the common ones.
  3. Your readers press Run. Python 3.13 executes in their browser and the output appears under the code, plots included. They can edit your example and run it again.

Frequently asked questions

How do I embed runnable Python code in my website?
Paste your code into the generator on this page and copy the iframe tag it produces. Add that tag to your HTML, a WordPress Custom HTML block, a Ghost HTML card, or your LMS editor. For Notion, paste the widget link into an Embed block instead. No plugin, no API key.
Is the embed widget free?
Yes, with no usage limits and no account. The widget carries a small "Powered by pythoncompiler.io" link.
Does embedded code run on a server?
No. The code runs in each reader's browser, so there are no execution queues and a traffic spike on your post costs you nothing.
Which Python features are supported inside embeds?
Python 3.13 with the full standard library, plus NumPy, Pandas, and Matplotlib. Plots render inline below the code. The one thing that does not work inside embeds is input(), which browsers restrict in iframes. Assign values to variables instead, or let readers click "Open in full editor".
Does the embed slow down my page?
No. The iframe loads lazily and only a small editor loads at first. The Python runtime starts downloading when a reader clicks Run, not before, so your page speed and Core Web Vitals stay untouched.

Built something with it? Tell us where you embedded it. Or keep exploring: the free online Python compiler, 116 interactive Python tutorials, and 50 practice problems with runnable solutions.