Skip to content
    Python SandboxPython 3.12 (Pyodide 0.26.1)
    Terminal Output
    Initializing Python Engine...
    Loading Pyodide 0.26.1 from CDN...
    © WebFiddle.xyz

    Online Python Compiler and Sandbox: Run Python 3.12 in Your Browser

    This online Python compiler runs Python 3.12 (Pyodide 0.26.1) directly in your browser tab. Pyodide is the CPython interpreter compiled to WebAssembly, so your script executes on your own device inside a Web Worker instead of on a remote server, which makes the page a Python sandbox you can use with no setup. Use this Python online editor for quick experiments, coursework, interview practice or checking a snippet from a tutorial: type your code, press Run Code and read the output in the terminal panel. There is no account to create and nothing to install.

    How to use the online Python compiler

    1. Open the Python sandbox and wait for the status bar to show Engine Ready. The first visit downloads the Pyodide runtime from the jsDelivr CDN; later visits load it from the browser cache.
    2. Write or paste Python code in the editor. A starter script that prints the interpreter version is loaded by default.
    3. Click Run Code. Anything you print() and any traceback appears in the Terminal Output panel.
    4. Click Clear to empty the output, or the reset icon to restore the starter script.
    5. Click Share to copy a link that reopens the same code for anyone you send it to.

    Features

    • Python 3.12 (Pyodide 0.26.1): the reference CPython interpreter compiled to WebAssembly
    • Runs in a Web Worker, so the editor stays responsive while a script executes
    • Most of the standard library works out of the box, including math, json, re, datetime, collections, itertools, dataclasses and asyncio
    • Top-level await, so asyncio code runs without wrapping it in asyncio.run()
    • Packages such as NumPy and pandas can be loaded on demand from the Pyodide package repository
    • Variables and imports persist between runs until you reload the page
    • Monaco editor with Python syntax highlighting in light or dark theme
    • Share button that copies a link with your code compressed into the URL

    What works and what doesn’t

    • input() cannot read from the keyboard. The code runs in a background worker with no interactive terminal, so assign test values in the script instead.
    • Third-party packages are not pre-loaded. import numpy raises ModuleNotFoundError until you load the package first, as shown in the NumPy example below.
    • Only packages that Pyodide has built for WebAssembly, or pure-Python wheels installed with micropip, can be used. Packages with other native extensions will not install.
    • Threads, subprocesses and raw sockets are unavailable in the browser, so modules such as urllib.request cannot open network connections. pyodide.http.pyfetch works for URLs that allow cross-origin requests.
    • GUI toolkits such as tkinter and turtle are not included, and files you write go to an in-memory file system that is cleared when the page reloads.
    • There is no stop button. A script stuck in an infinite loop keeps the worker busy until you reload the page.

    Example programs

    Count words with collections.Counter

    Uses only the standard library, so it runs immediately. Counter.most_common returns the most frequent items first.

    from collections import Counter
    
    text = """the quick brown fox jumps over the lazy dog
    the dog barks and the fox runs"""
    
    counts = Counter(text.split())
    for word, n in counts.most_common(3):
        print(f"{word:>6}: {n}")
    

    Load NumPy in the Python sandbox

    Pyodide packages are downloaded on first use. Load the package with pyodide_js.loadPackage, then import it as usual. The first run takes a few seconds while the package downloads.

    import pyodide_js
    await pyodide_js.loadPackage("numpy")
    
    import numpy as np
    
    matrix = np.arange(1, 10).reshape(3, 3)
    print(matrix)
    print("Column sums:", matrix.sum(axis=0))
    print("Mean:", matrix.mean())
    

    Run Python online with asyncio and dataclasses

    The sandbox supports top-level await, so you can await coroutines directly. asyncio.gather runs both tasks concurrently, so the total wait is about 0.5 seconds rather than 0.8.

    import asyncio
    from dataclasses import dataclass
    
    @dataclass
    class Job:
        name: str
        seconds: float
    
    async def run(job: Job) -> str:
        await asyncio.sleep(job.seconds)
        return f"{job.name} finished after {job.seconds}s"
    
    jobs = [Job("download", 0.5), Job("resize", 0.3)]
    for line in await asyncio.gather(*(run(j) for j in jobs)):
        print(line)
    

    Frequently asked questions

    Is this online Python compiler free, and does my code run on a server?

    Yes, it is free and needs no account. When you press Run Code, your script executes inside your own browser in a Web Worker, using Pyodide, which is CPython compiled to WebAssembly. The code is not uploaded; it only leaves your device if you create a Share link and send it to someone.

    Which Python version does the sandbox run?

    It runs Python 3.12 (Pyodide 0.26.1). Pyodide 0.26.1 bundles CPython 3.12, so features such as match statements, nested quotes inside f-strings and the typing syntax added in 3.12 work. Run import sys followed by print(sys.version) to see the exact build string the interpreter reports.

    Is Python compiled or interpreted?

    Both, in a sense. CPython first compiles your source code into bytecode, the internal representation of a Python program, and its virtual machine then executes that bytecode. Pyodide is CPython compiled to WebAssembly, so the same two steps happen here inside your browser. That is why a syntax error anywhere in the script is reported before any of it runs.

    How do you compile Python?

    Usually you do not need to: the interpreter compiles a script to bytecode automatically when it runs. To do it explicitly, python -m py_compile or python -m compileall writes .pyc bytecode files, and tools such as PyInstaller bundle a script with an interpreter into an executable. In this online Python compiler there is no separate step; press Run Code.

    Can I use NumPy, pandas or other pip packages?

    Yes, but they are not pre-loaded. First run import pyodide_js and await pyodide_js.loadPackage("numpy"), replacing numpy with the package you need, then import it. Pure-Python wheels from PyPI can be installed with micropip once micropip itself is loaded the same way. Packages with native code work only if Pyodide provides a WebAssembly build.

    Why does input() not work in the Python sandbox?

    Your code runs in a background Web Worker that has no interactive terminal, so it cannot pause and wait for keyboard input. Replace input() calls with fixed values or a list of test inputs while you experiment, then restore them when you run the script in a local Python installation.

    Can I use this Python online editor for learning or interview practice?

    Yes. It suits algorithm and data structure practice, working through tutorials and checking small scripts, because the standard library is available and output appears straight away. It does not replace a local setup when you need files that persist, network sockets, GUI toolkits or packages without a WebAssembly build.

    How do I share Python code from the sandbox?

    Click Share in the toolbar. The sandbox compresses your code into a link and copies it to your clipboard. Anyone who opens the link sees the same code in the editor and can run it in their own browser. Nothing is stored on a WebFiddle server, so very long scripts produce long URLs.

    Embed this sandbox

    Paste this iframe into any web page and readers can run code without leaving it. The snippet travels in the URL, so there is nothing to host and no account to create. Open the sandbox, write your example, press Share, then append that link’s query string to the embed URL to preload it.

    <iframe src="https://webfiddle.xyz/embed/python" width="100%" height="480" loading="lazy"
            style="border:1px solid #ddd;border-radius:8px"
            title="WebFiddle python sandbox"></iframe>
    Preview the embed

    Related articles

    Related sandboxes

    Official documentation