About Turbo Pascal Online
A free Turbo Pascal 7 IDE that runs in your browser: the Borland-blue editor, an 80×25 text-mode console, and a real Pascal interpreter. Nothing to install, no account, no server round-trip -- your code is compiled and run by JavaScript on your own machine.
What Turbo Pascal was
Borland released Turbo Pascal in 1983 for CP/M and DOS, written by Anders Hejlsberg. It cost $49.95 at a time when compilers routinely cost hundreds of dollars, and it was fast enough to compile a whole program between keystrokes -- editor, compiler, and runtime in a single program that fit comfortably on a floppy disk.
Version 7, released in 1992, is the one most people remember: the blue full-screen IDE, the
gray menu bar across the top, the F-key hints along the bottom, F9 to compile and
Ctrl+F9 to run. It was the machine that a generation of programmers learned on,
and for many countries it stayed the standard teaching environment well into the 2000s. This
site recreates that environment closely enough to be useful for the same purpose.
How it works
There is no DOSBox and no emulator here, and nothing is sent to a server to be compiled. The Pascal implementation is hand-written in TypeScript and runs entirely in your browser tab:
- Lexer → parser → interpreter. A recursive-descent parser builds an AST, and a tree-walking evaluator executes it.
- A real text-mode screen. Program output goes to an 80×25 character grid drawn on a canvas, using the 16-color EGA palette, with a blinking cursor -- so
GotoXY,TextColor, andTextBackgrounddo what they did on a VGA text console. - Blocking input that doesn't block the page. Evaluation is asynchronous all the way down, so
ReadLnandReadKeygenuinely wait for you without freezing the browser. - The editor is a character grid too -- not a text box -- with its own cursor, selection, undo, and TP7 syntax coloring: reserved words white, comments gray, everything else yellow.
Your work is kept in browser local storage, so a reload doesn't lose it, and File › Share link... turns the current program into a link you can send to someone for 30 days.
What the interpreter supports
- Program structure:
program,const,type,var, nested procedures and functions, recursion,varparameters - Control flow:
if/then/else,while,repeat/until,for/to/downto,case, plusBreak,Continue, andExit - Types: integers, reals, booleans, chars, strings, arrays, and records
- Built-ins:
Write/WriteLn,Read/ReadLn,Length,Copy,Pos,Ord,Chr,Abs,Sqr,Sqrt,Sin,Cos,Round,Trunc,Random,Randomize, and more - The
Crtunit:ClrScr,GotoXY,TextColor,TextBackground,WhereX,WhereY,Delay,ReadKey,KeyPressed - The
Graphunit: real pixel graphics, described below
Graphics
InitGraph switches the screen out of text mode into 640×480 with 16 colors --
VGA/VGAHi, the mode nearly every Turbo Pascal graphics program asks for -- and
CloseGraph switches back, exactly as the real thing did. It is emulated with a
pixel framebuffer, so the drawing is genuine: PutPixel, Line,
Rectangle, Bar, Bar3D, Circle,
Arc, Ellipse, FillEllipse, PieSlice,
DrawPoly, FillPoly, FloodFill, the twelve
SetFillStyle patterns, SetLineStyle, XOR write mode, viewports, and
OutText/OutTextXY. See CUBE3D.PAS for a
worked example.
Compile errors and runtime errors carry a line and column, and the IDE jumps the cursor straight to the offending character the way the original did.
Not supported
This targets the textbook subset of Turbo Pascal, which covers most course exercises and
retro-programming curiosity but not everything Borland shipped. Missing: object
and OOP, file I/O, units other than the built-in Crt and Graph,
pointers, sets, and inline assembly. Within Graph, the sprite calls
(GetImage, PutImage, ImageSize) need pointers and
GetMem, so they are absent, and the stroked BGI fonts fall back to the default
8×8 one. Real numbers print as trimmed fixed-point rather than Turbo Pascal's scientific
notation, which reads better in a browser.
Keyboard shortcuts
| F9 / Alt+F9 | Compile |
| Ctrl+F9 | Compile and run |
| Alt+F5 | Toggle the user screen (your program's output) |
| F2 | Save the current file to disk |
| F3 | Open a sample or a .pas file from your machine |
| F6 / Shift+F6 | Next / previous edit window |
| Alt+F3 | Close the active window |
| Alt+BkSp | Undo |
| Shift+Del / Ctrl+Ins / Shift+Ins | Cut / copy / paste |
| Alt+F10 | Editor local menu (right-click works too) |
| Alt+X | Exit |
The menu bar is reachable with Alt plus the highlighted letter -- Alt+F for File, Alt+R for Run, and so on.
Where to start
The IDE opens on WELCOME.PAS; press Ctrl+F9 to run it. Press
F3 for the rest, or read them here first on the
sample programs page -- ten annotated programs from "Hello, World!"
up to a rotating wireframe cube and a Mandelbrot renderer.
The whole thing is open source: github.com/mikla/tp-ide.