Home › Developer Tools › Online Python Compiler

Online Python Compiler

Write Python 3 and run it instantly, right in your browser. Feed input() from the stdin box, import numpy, pandas or matplotlib, click a traceback to jump to the failing line, and share your program with a link.

Last updated:

main.py
Ln 1, Col 1Ctrl + Enter to run · Tab indents 4 spaces
Output
Starting…

Python 3 runs on your device with Pyodide (CPython compiled to WebAssembly). The first run downloads the runtime (about 10 MB, cached afterwards); imports such as numpy and pandas are loaded automatically. Your code is never uploaded.

Advertisement
Advertisement

How to use the Online Python Compiler

  1. Write or paste Python in the editor, open a .py file, or pick an example.
  2. Add input in the Input (stdin) box if your program calls input(): one line per call.
  3. Press Run code or Ctrl + Enter. The first run downloads the Python runtime; later runs start instantly.
  4. Fix errors by clicking the line link in a traceback to jump to that line in the editor.
  5. Share or save your program with Copy share link or Download.

How this Python compiler works

There is no server behind the Run button. The page loads Pyodide, a build of the official CPython interpreter compiled to WebAssembly, inside a Web Worker. Your program is compiled to Python bytecode and executed by that interpreter on your own CPU, which is why output appears without network round trips and why your code stays private. Each run starts with a fresh __main__ namespace, so variables from a previous run do not leak into the next one, while packages you already loaded stay in memory and import instantly.

Two things are handled differently from a terminal: input() reads from the Input (stdin) box instead of waiting for keystrokes, and plt.show() turns each open matplotlib figure into an image in the output panel.

Browser Python vs. desktop Python

FeatureIn this compilerTip
Standard library (math, re, json, datetime, collections, itertools, dataclasses, decimal, fractions)WorksSame behavior as CPython 3.12
input() and sys.stdinReads the stdin boxOne line per input() call
numpy, pandas, scipy, sympy, scikit-learn, matplotlibLoaded on importFirst import downloads the package (a few MB)
open() filesIn-memory file systemFiles vanish when Python restarts
time.sleep()Works, but blocks the runCounts toward the time limit
threading, multiprocessing, subprocessNot availableUse plain loops or asyncio
requests, sockets, urllib to other sitesNot availableBrowsers do not allow raw sockets
tkinter, pygame windows, turtleNot availableDraw charts with matplotlib instead

Reading a Python traceback

A traceback lists the calls that led to an error, oldest first. Read it from the bottom up: the last line names the exception type and message, for example KeyError: 'grace', and the File "main.py", line N entry just above it is where Python stopped. Common ones: NameError (a variable or function name is misspelled or used before it is defined), IndentationError (mixed tabs and spaces or a missing indent after a colon), TypeError (for example adding a string to a number: convert with int() or str()), IndexError and KeyError (a list position or dictionary key that does not exist) and EOFError (your program asked for more input than the stdin box contains).

Frequently asked questions

Is Python compiled or interpreted?

CPython, the standard Python implementation, compiles your source code to bytecode and then interprets that bytecode in a virtual machine. This tool runs the same CPython, itself compiled to WebAssembly by the Pyodide project, so your code executes inside your browser rather than on a remote server.

How do I use input() in this online compiler?

Type the values your program reads into the Input (stdin) box, one line for each input() call, before you press Run. Each call takes the next line and the value is echoed after the prompt, like in a terminal. If the box runs out of lines, input() raises EOFError. sys.stdin.read() returns the whole box.

Can I use numpy, pandas and matplotlib?

Yes. When your code imports a package that Pyodide provides, such as numpy, pandas, scipy, sympy, scikit-learn or matplotlib, it is downloaded and loaded automatically before your program runs. matplotlib figures are drawn as PNG images below the output. Packages with C extensions that Pyodide does not build, and anything needing network sockets or threads, are not available.

Which Python version does it run?

Pyodide 0.26 includes CPython 3.12, so f-strings, match statements, dataclasses, type hints and the rest of modern Python work. The exact version is shown in the status bar once the runtime has loaded.

What happens if my code has an infinite loop?

Python runs in a separate Web Worker, so the page stays responsive. When a run exceeds the time limit you chose (10 seconds by default), or you press Stop, the worker is shut down and Python restarts on the next run. Use a higher limit for long calculations.

Can my program read files or access the internet?

Your program has a private in-memory file system, so open() can write and read files during a run, but it cannot see files on your computer; open a .py file into the editor instead. Raw sockets, subprocess and threads are not available in the browser, so libraries such as requests do not work.

Is my code private, and how do share links work?

Code runs entirely on your device and is never uploaded. A share link stores your code and stdin, compressed, after the # in the URL; that part is not sent to any server. Opening a shared link loads the code but does not run it until you press Run.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

JavaScript Online CompilerWrite and run JavaScript in your browser with a console, timing, error lines and share links.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.JSON to Python ClassGenerate Python dataclasses, Pydantic models or TypedDicts with type hints from JSON.PHP Online CompilerRun PHP 8 code in your browser with output, HTML preview, error lines and share links.JSON EditorEdit JSON in a tree and as code side by side: add, rename, drag, change types, undo and download.Unzip FilesOpen and extract ZIP files online.RAR & 7z ExtractorOpen RAR, 7z and other archives online and extract files.Regex TesterTest and debug regular expressions live.File Info ViewerCheck file size, type, date and MD5/SHA hashes.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.DOCX ViewerOpen and read Word .docx files in your browser, then print or save them as HTML.EPUB ReaderOpen and read EPUB e-books in your browser with pages, a table of contents and font controls.What Is My BrowserSee your browser, version, OS, engine, screen and which web features it supports.Font ViewerPreview TTF, OTF, WOFF and WOFF2 fonts with sample text, waterfall, glyphs and metadata.Markdown EditorWrite Markdown with a toolbar, live split preview, autosave and .md or HTML export.Regex Cheat Sheet75+ ready-to-use regex patterns for emails, URLs, IPs and dates, each with a live test box.JavaScript Keycode FinderPress any key to see its JavaScript key, code, keyCode, which, location and modifiers.QR Code ScannerScan QR codes with your camera or from an image and safely read the link or text.RAID CalculatorUsable capacity, efficiency and fault tolerance for RAID 0, 1, 5, 6, 10, 50 and 60 arrays.JSONPath TesterTest JSONPath expressions live: filters, slices, wildcards and recursive search, with matches highlighted.Mermaid Diagram EditorWrite Mermaid code and see flowcharts, sequence, Gantt and ER diagrams live. Export SVG or PNG.Country Codes ListSearch ISO 3166 alpha-2, alpha-3 and numeric country codes with calling codes and TLDs.CSS Selector TesterTest CSS selectors on your HTML: highlighted matches, match count and specificity.Git Cheat SheetSearchable Git command reference by task, with copy buttons and an undo/rename/fix wizard.HAR File ViewerOpen a .har file to see a waterfall timeline, headers, bodies, timings and size totals.jq PlaygroundRun jq filters on JSON in your browser with live output, flags and an example library.Markdown Cheat SheetInteractive Markdown syntax reference: edit every example and see the live rendered preview.Regex ExplainerPaste a regular expression and get a plain-English breakdown, railroad diagram and flag notes.XPath TesterTest XPath expressions on XML or HTML: highlighted matches, node paths, values and examples.EML File ViewerOpen .eml email files to read the message, headers and raw source and save attachments.Graphviz Online ViewerWrite Graphviz DOT code and render graphs live; switch layout engines, export SVG or PNG.Jupyter Notebook ViewerOpen .ipynb files and read code, Markdown, math, tables, plots and errors without Python.LaTeX Table GeneratorEdit a table like a spreadsheet or paste from Excel and get LaTeX tabular or booktabs code.Log File ViewerOpen huge log files with level colors, regex and time filters, JSON pretty-print and tail -f.Logic Gate SimulatorBuild logic circuits with AND, OR, NOT, XOR gates and flip-flops; see live outputs and truth tables.MSG File ViewerOpen Outlook .msg emails in your browser: sender, recipients, body, headers and attachments.Online Code EditorVS Code-style editor in your browser: tabs, 50+ languages, find/replace, autosave.Online Hex EditorOpen any file as hex and ASCII, edit bytes, search, inspect values and save the result.Sorting Algorithm VisualizerWatch bubble, insertion, merge, quick, heap and radix sort step by step with live counters.Lottie ViewerOpen Lottie JSON or .lottie files to play, pause, scrub frames, change speed and see details.Diff ViewerPaste a git diff or .patch file and view it side by side or inline, with file navigation.EditorConfig GeneratorBuild an .editorconfig with indent, charset, line endings and trim rules per file pattern.Folder Compare ToolCompare two folders by file list, size and SHA-256 hash, then open a text diff of changed files.Glob Pattern TesterTest glob patterns like **/*.js, {a,b} and !exclusions against a list of file paths.JMESPath TesterEvaluate JMESPath expressions against JSON live, the query language used by the AWS CLI.MongoDB Query TesterTest MongoDB find filters, projections and aggregation pipelines on sample JSON documents.Semantic Version CalculatorBump, compare, sort and test SemVer versions against npm ^, ~ and x ranges.XSLT TesterRun an XSLT 1.0 stylesheet on XML in your browser and see the output as HTML, XML or text.ASCII Diagram EditorDraw boxes, arrows and text on a character grid and copy plain-text diagrams for code and READMEs.DBF File ViewerOpen dBase .dbf files and shapefile tables, search and sort records, export CSV or XLSX.MBOX File ViewerOpen .mbox mail archives: list and search messages, read them, save attachments, export EML.MDB File ViewerOpen Access .mdb and .accdb databases in your browser: list tables, view rows, export CSV.Shapefile ViewerView zipped shapefiles on a map with the attribute table, then export to GeoJSON or CSV.PlantUML EditorWrite PlantUML and see sequence, class, activity and more diagrams live. Export SVG or PNG.
See all 53 Code Playgrounds & Testers →