Dart playground

Run Dart online

Write and run Dart online with Dart 3. A free Dart compiler in your browser: see what print shows and every error, read input from stdin, no sign-up.

Code main.dart

// Welcome to the coding.kitty Dart playground.
// Press Run (or Ctrl+Enter) to see what this prints.

import 'dart:io';

class Cat {
  final String name;
  final int age;

  Cat(this.name, this.age);

  String describe() => '$name is $age and says meow';
}

void main() {
  final cats = [Cat('Miko', 3), Cat('Nola', 5), Cat('Baymax', 1)];

  // Youngest first.
  cats.sort((a, b) => a.age.compareTo(b.age));

  for (final (i, cat) in cats.indexed) {
    print('${i + 1}. ${cat.describe()}');
  }

  // Type a name in the Input box and press Run again to see this line.
  final name = stdin.readLineSync();
  if (name != null && name.isNotEmpty) {
    print('Hello, $name!');
  }
}
Output

Press Run to see what your code prints.

About this Dart playground

This is a Dart compiler you can use straight away. Write Dart in the editor, press Run, and your program is compiled and run on the Dart VM. The output appears next to it: everything it prints, any compile error with its line number, any exception with its stack trace, and how long it took.

It runs Dart 3.13 in an isolated sandbox on our servers, the same way dart run main.dart does on your own machine, so null safety, records, patterns and sealed classes all behave as they do there. It is free, with nothing to install and no account needed.

What you can run

  • Dart 3.13, running one file per run, saved as main.dart.
  • Standard library only. The Dart core libraries are there: dart:core (List, Map, Set, String and the rest), dart:math, dart:convert (JSON and UTF-8), dart:async (Future and Stream), dart:collection, dart:typed_data, dart:isolate and dart:io for reading input. There is no package installer, and programs have no network access.
  • Limits: 10 seconds and 256 MB of memory per run. Output past 64 KB is cut off, code can be up to 64 KB and input up to 16 KB.
  • Fair use: 5 runs a minute and 50 a day without an account, 10 a minute when you are signed in.

Reading input

Open the Input box under the editor and type what your program should read. It arrives as standard input: import dart:io, and stdin.readLineSync() reads the next line. With the box empty, or once every line is read, it returns null.

import 'dart:io';

final age = int.parse(stdin.readLineSync() ?? '0');

Frequently asked questions

Is this online Dart compiler free?

Yes. There is no sign-up and no limit on how much you can write. Signed-out visitors get a quick, usually invisible bot check when they press Run, and a fair-use cap of 5 runs a minute and 50 a day. Signing in raises it to 10 runs a minute.

Which version of Dart does it run?

Dart 3.13 (stable) on the Dart VM, on Linux. Sound null safety is always on, and records, patterns, switch expressions, sealed classes and extension types all work.

Can I use Flutter or packages from pub.dev?

No. The playground runs one file, main.dart, against the Dart core libraries. There is no pub, no pubspec.yaml and no network, so packages from pub.dev cannot be added, and Flutter needs a screen to draw on, which a program here does not have. Everything in the core libraries, dart:io included, is available.

How do I read input in the Dart playground?

Type it in the Input box under the editor before you press Run, then read it with stdin.readLineSync() from dart:io. It returns one line at a time as a String, and null when there is nothing left. To read a number, parse the line: int.parse(line).

Why does a run take a couple of seconds?

Each run starts a fresh Dart VM, which compiles your file and then runs it, and that takes a second or two even for a small program. That time counts towards your program's own limit, so there is no separate compile step to wait for.

Why did my program stop with a time-out?

Each run gets 10 seconds and 256 MB of memory. A program that goes past either is stopped. That includes compiling your file. The usual cause is a loop that never ends, such as a while (true) loop without a break.

Is my code saved or shared?

Your code is kept in your own browser so it is still there next time, and nowhere else. When you press Run it is sent to our code runner, run once in a sandbox, and thrown away. We do not store it or show it to anyone.

Keep going

Also in the playground: Python, JavaScript, TypeScript, SQL, Bash, C, C++, Go, Rust, Java, C#, Ruby, PHP, Lua, R, Swift.