Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time


Brython (Browser Python) is an implementation of Python 3 running in the browser, with an interface to the DOM elements and events.

Here is a simple example of an HTML page running Python:


        <script type="text/javascript" src="/path/to/brython.js"></script>


        <script type="text/python">
        from browser import document, alert

        def echo(event):

        document["mybutton"].bind("click", echo)

        <input id="zone"><button id="mybutton">click !</button>



To use Brython, all there is to do is:

  1. Load the script brython.js.
  2. Write Python code inside tags <script type="text/python">.

Main features

Brython supports the syntax of Python 3, including comprehensions, generators, metaclasses, imports, etc. and many modules of the CPython distribution.

Since version 3.8.0, Brython implements the Python version of the same major / minor version number.

It includes libraries to interact with DOM elements and events, and with existing Javascript libraries such as jQuery, D3, Highcharts, Raphael etc. It supports the latest specs of HTML5/CSS3, and can use CSS Frameworks like Bootstrap3, LESS, SASS etc.

Getting started

Zero install !

The most simple way to get started, without anything to install, is to use the distribution available online through jsDelivr. You can choose the latest stable release :

<script type="text/javascript"

The previous code will allow you to use raw python code, but if you import modules from the standard library you have to load a single javascript file with the available stdlib:

<script type="text/javascript"

jsDelivr supports version ranges, so if you want the latest of the 3.12.x versions:

<script type="text/javascript"
<script type="text/javascript"

or the latest of the 3.x.y versions:

<script type="text/javascript"
<script type="text/javascript"

If you want to use the latest development version, you can load these scripts instead:

<script src=""
<script src=""

Local install

To install Brython locally, if you have a CPython distribution with pip :

pip install brython

then create a new directory and run

brython-cli install

or by loading the latest version of the Brython zip file from the releases page.

In both cases, the distribution includes brython.js (the core Brython engine) and brython_stdlib.js (a bundle of all the files in the standard distribution).

It also includes the page demo.html that shows a few examples of how you can interact with a web page using Python as the scripting language : create new elements, access and modify existing elements, create graphics, animations, send Ajax requests, etc.

Test Brython online

If you want to test Brython online you can visit the following:

Gallery of examples

There is a gallery of examples where you can see simple and advanced examples using vanilla Brython or interacting with Javascript libraries.


You can start by reading the official Brython tutorial.

Full documentation is available on the official site. You can read the docs in English and French.

Curious about how Brython works ?

A tutorial explains how to build Android applications with Brython.

Community (questions, feedback, issues, new features, ...)

You can subscribe and post to the mailing list.

If you find a bug/issue or do you want to see a new feature in Brython, please, open a new issue.

If you want to contribute to Brython, please read the contributing guide.

Thank you

  • BrowserStack for providing an access to their online testing environment.