Please enable JavaScript to use CodeHS

Meet Karel the Dog

Giving commands to a computer is like giving commands to a dog

Karel is a very good dog with one job: follow your instructions exactly. Millions of students write their first line of code by helping Karel move through a grid world, turn left, and fetch tennis balls.

Who Is Karel?

Karel Lives in a Grid World

Karel's world is a simple grid of streets and avenues. Karel can walk forward one square, turn to the left, pick up a tennis ball, and put a tennis ball down. That is Karel's entire vocabulary:

  • move();Karel walks forward one square
  • turnLeft();Karel turns 90 degrees to the left
  • putBall();Karel puts down a tennis ball
  • takeBall();Karel picks up a tennis ball

Your job is to write instructions Karel can follow. If your program says move, Karel moves. If it says move into a wall, Karel bonks the wall and tells you something went wrong. Every program you write plays out right in front of you, so you can literally watch your code think.

Why Karel Works

Four Commands. Then You Teach Karel New Tricks.

Here is Karel's secret: the vocabulary is small on purpose. Karel cannot even turn right. The moment a student wants Karel to turn right, they discover the single most important idea in programming: if the command you need does not exist, you can build it, name it, and use it like it was always there.

That is a function. That is abstraction. Students do not learn these ideas because a textbook says they matter. They learn them because Karel genuinely needs them, and that motivation makes the concepts stick.

  • Concepts before syntax. Students reason about sequences, functions, loops, and conditions while the code stays small enough to read out loud.
  • Decomposition by instinct. Big problems become small named steps, because that is the only way to get a dog across a grid.
  • Instant, visible feedback. Every bug is a dog doing something silly on screen, which makes debugging feel like detective work instead of failure.
Try It Right Now

Take Karel for a Walk

This is the real CodeHS editor, the same one students use in class. Write a few commands, press Run, and watch Karel go. No account, no install, no leash required.

  • Make Karel run a lap around the world
  • Drag the speed slider and watch each command play out
  • Put a tennis ball in every corner
  • Write a turnRight() function
  • March Karel into a wall and read the error
A Serious Editor for a Silly Dog

A Real IDE, Sized for a Beginner

Karel is whimsical. The tools around Karel are the real thing: the same editor students keep using through AP Computer Science, with the controls a first-time programmer actually needs turned on.

Speed Up, Slow Down

Drag the slider from turtle to rabbit and Karel runs anywhere between thoughtful slow motion and full zoomies. Slowing down turns a program into a story you can follow line by line.

Step Forward, Step Back

Advance one command at a time and watch Karel take exactly one step, or step backward to rewind the world. Being able to go back is what lets students hunt a bug instead of restarting.

Debug With Breakpoints

Click the gutter to set a breakpoint and the program pauses there, with the current line highlighted as Karel moves. Seeing exactly where expectation and reality split is how debugging clicks.

Code History

Every revision saves automatically, so students can scrub back through their own history to see how a solution evolved, recover a version that worked, or show their work.

Help When You're Stuck

Plain-language error messages that say what Karel tried to do, a built-in documentation tab for every command, and moderated AI hints that nudge toward the fix without handing over the answer.

Runs Anywhere

Works in the browser on any device, Chromebooks included, with nothing to install. Karel speaks JavaScript, Python, and Java, so the same dog can teach whichever language the course needs.

Why It Teaches So Well

Students Can Watch Their Code Think

A beginner's first bug is usually invisible: a wrong value in a variable nobody can see. With Karel the bug walks across the screen. The program runs as a sequence of things a dog does, so a mistake is something students watch happen and can point at, and the fix is a change they can predict before pressing Run.

  • Complex ideas become small puzzles. "Use a while loop" is abstract. "Get Karel to the wall no matter how far away it is" is a puzzle with an obvious win condition, and solving it teaches the loop.
  • It works with the screens off. Forward, left, and turning are things a class can act out before anyone writes a line, on a floor grid or on graph paper. Karel's first lessons pair naturally with unplugged and offline activities for direction, motion, and giving precise instructions.
  • The ceiling is far higher than it looks. Four commands, a few conditions like frontIsClear and ballsPresent, loops, and functions add up to a Turing complete language. Anything a computer can compute can be expressed in Karel, so students can genuinely build anything with it, including art.
The Origin Story

An Homage to a Very Good Robot

In 1981, Stanford professor Rich Pattis created Karel the Robot, a tiny robot in a grid world named for Karel Čapek, the playwright who gave the world the word "robot," and it became one of the most beloved ways to teach programming ever made.

The founders of CodeHS learned and taught with Karel at Stanford, and when they set out to teach the world to code they brought Karel along in a friendlier shape: a dog who fetches tennis balls instead of beepers. Same grid, same big ideas, significantly more tail wagging.

Karel Posts

Follow Karel the Dog

Karel has thoughts. Mostly about tennis balls, occasionally about recursion. Follow along for Karel news, student creations, and an unreasonable amount of grid-world humor.

Ready to Code With Karel?

Free for students and teachers. The full Intro to Programming with Karel course comes with lessons, videos, exercises, and a dog who never gets tired of fetch.