% Online Prolog compiler
% Write Prolog code in this online editor and run it
greet(Name) :- format('Hello, ~w!~n', [Name]).
:- greet('Tutorsbot').
Prolog is a logic programming language used in AI and computational linguistics. Run Prolog code instantly in your browser.
:- write("Hello, Tutorsbot!"), nl.Paste the snippet into the editor above and hit Run to see the output instantly.
Prolog (PROgrammation en LOGique) is a declarative logic-programming language created in 1972 at the University of Marseille. You describe facts and rules; the engine searches for proofs by unification and backtracking. Prolog is foundational to computational linguistics (Definite Clause Grammars were invented to describe natural languages), expert systems, and classical AI research.
SWI-Prolog's installer is hefty and the interactive REPL takes a moment to learn. A browser sandbox is a friction-free way to experiment with backtracking, unify two terms, or trace a search. SWI-compatible Prolog runs in the sandbox; you can write clauses and query them within seconds.
Expert systems and rule engines, natural-language parsing via DCGs (Definite Clause Grammars), constraint solvers, theorem provers, puzzle solvers (the classic Einstein/Zebra puzzle is a favourite teaching example), and database queries issued as Prolog goals (?-). The sandbox runs SWI-compatible Prolog.
Paste a fact or a rule, then a goal — for example likes(mary, food). likes(john, wine). likes(john, mary). ?- likes(mary, X). — and hit Run. The query's answers appear in stdout. The highlighter understands Prolog atoms, variables (capitalised identifiers), predicate syntax, and the :- operator that separates rule head from body.
An online Prolog compiler is unusual among language sandboxes because there's no "compile" step in the traditional sense — you're loading facts and rules into a genuine SWI-compatible engine and letting it search for proofs by unification and backtracking. No installer, no PATH configuration, just a knowledge base and a goal. It works as a free Prolog interpreter for testing whether a rule actually unifies the way you expect before you build a larger expert system around it.
Prolog exercises tend to get re-implemented in more mainstream languages for comparison — the Online Python Compiler is useful for that, and the Online Julia Compiler covers the numerical/scientific-computing side where logic programming sometimes overlaps with constraint solving.
To run Prolog code in the browser, load a few facts and rules, then pose a query with ?- — the solver returns bindings for every solution it can find, the same way a REPL session would. It's the closest thing to how most logic-programming courses actually teach unification: define a knowledge base, ask a question, watch backtracking work through the search space one answer at a time.
Racket shares Prolog's academic roots in language and semantics research, so the Online Racket Compiler is a natural next stop. The complete language list is on the Online Compiler hub.
SWI-Prolog's installer differs enough across Windows, macOS, and Linux that a classroom of students comparing notes on a backtracking bug can end up debugging installation quirks instead of the actual logic. This free Prolog interpreter removes that variable — everyone runs the same engine version, so a knowledge base that unifies correctly here will unify the same way for anyone else with the link.
For comparing logic programming against a functional, S-expression-based approach, the Online Racket Compiler sits on the same editor, and the free online compiler hub lists everything else.
Switching languages mid-project? Every compiler below runs on the same zero-setup editor — open a tab and you are coding in seconds.
Programiz, OneCompiler, OnlineGDB and JDoodle are the online Prolog compilers people compare most often. Here is how Tutorsbot's Prolog compiler stacks up.
| Compiler | Editor | Signup | Known for |
|---|---|---|---|
| Tutorsbot | Monaco (VS Code engine) with syntax highlighting | Never required | 34+ languages in one professional editor, shareable URLs |
| Programiz | Basic code editor | Not required to run | Beginner-friendly layout, paired with its own tutorials |
| OneCompiler | Basic code editor | Not required to run | Broad language coverage in a lightweight editor |
| OnlineGDB | Editor with a step-through debugger | Not required to run | GDB-based visual debugging (breakpoints, variable inspection) |
| JDoodle | Basic code editor | Not required to run | Self-reports 110+ languages, plus an API for embedding compilers |
Comparison based on each platform’s own publicly listed features as of September 2026. Feature sets change — verify current details on each provider’s own site before relying on them.