An interactive playground for Scala
Clone or download
Latest commit 2d3ce57 Dec 11, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
api/src/main/scala/com.olegych.scastie.api fix saving progress (mongo doesn't accept $ in field names) Dec 9, 2018
balancer/src fix probable error Dec 9, 2018
bin upgrade scalafmt Jul 13, 2017
client display progress on save (which does run) Dec 9, 2018
demo Client: add some color to the console! Sep 21, 2017
deployment Remove ensime runner Aug 21, 2018
end-to-end/src/test/scala increase code style line length, the default is inadequate Sep 11, 2018
instrumentation/src detect IOApp from cats Dec 10, 2018
migration/src/main increase code style line length, the default is inadequate Sep 11, 2018
project update scala version Dec 9, 2018
runtime-scala Code folding Sep 8, 2017
sbt-api/src/main/scala/sbtapi hack to detect if sbt if logging or if it's a user println Feb 24, 2017
sbt-runner/src workaround for #423 Dec 10, 2018
sbt-scastie/src/main/scala/com.olegych.scastie.sbtscastie increase code style line length, the default is inadequate Sep 11, 2018
server/src remove blocking, this will hopefully fix #398 Sep 19, 2018
storage/src increase code style line length, the default is inadequate Sep 11, 2018
utils/src increase code style line length, the default is inadequate Sep 11, 2018
.gitignore Deploy locally Oct 17, 2017
.sbtopts make sbt release memory to os during development Dec 9, 2018
.scalafix.conf Code folding Sep 8, 2017
.scalafmt.conf fix scalafmt screw up encoding Sep 11, 2018
.travis.yml Use mongodb to store snippets Aug 10, 2018 Remove ensime runner Aug 21, 2018
LICENSE worksheet mode Jan 18, 2017
README.MD Bump Scala to 2.13.4 Oct 21, 2017
build.sbt increase code style line length, the default is inadequate Sep 11, 2018
default.nix update links to sbt dist Jul 11, 2018 Refactor sbt-runners to use NonBlockingProcess Oct 12, 2017 Refactor sbt-runners to use NonBlockingProcess Oct 12, 2017


Build Status Join the chat


raycasting demo

What is Scastie?

Scastie is sbt in your browser. You can:

  • Use any version of Scala
  • Use alternate backends such as Dotty, Scala.js, Scala Native, and Typelevel Scala.
  • Use any publicly available library
  • Share Scala programs with anybody
  • Embed Scastie into your own website or library user guide.

How does it work?

When a user evaluates their code, the browser sends all its input to our server. We run your code in an isolated Java Virtual Machine on our servers. We integrated a Scaladex interface to allow you to search the Scala ecosystem and include any published Scala library in your project. You don’t need to remember what the latest version number of a particular library is anymore!

The output is streamed back to the user. A protocol will allow the client to interpret different events such as compiler errors, runtime exceptions, instrumentation, console output, etc.

We also support a worksheet mode, which feels much like a worksheet in an IDE. It lets a user write code as top-level expressions, without having to put your code inside of a class or object with a main method. Worksheet mode gives you two ways to interleave your results; on the one hand, when an expression is evaluated, you can see the value and type of the evaluated expression to the right of the code that you wrote. On the other hand, worksheet mode also makes it possible to do a kind of literate programming; that is, you may interleave code and HTML blocks much like in notebook environments such as iPython notebooks.

How do I embed Scastie?

You can embed a snippet with two different ways. You can embed a resource that was previously saved or you can convert code to a snippet.

Embedded Resources


Any saved resource can be embedded via a script tag by appending ".js" to its URL.

<!-- Annonymous Resource -->
<script src=""></script>

<!-- User's Resource -->
<script src=""></script>
<script src=""></script>

The embedding will be patched at the location of the script tag.

It's also possible to adjust the theme via the GET parameter theme. For example:

<script src=""></script>

The theme can be dark or light. The default value is light. It's also possible to customize the css.

Take a look at:

Via Javascript

<!-- Embedding Script -->
<div id="resource-1"></div>
<div id="resource-2"></div>
<div id="resource-3"></div>

<script src=""></script>

window.addEventListener('load', function() {
  scastie.Embedded('#resource-1', { 
    base64UUID: "CJ8KTL98QAiWvoVUPI3kXg"

  scastie.Embedded('#resource-2', {
    user: "MasseGuillaume",
    base64UUID: "33D4P3ysQCq2em2MRiv5sQ"

  scastie.Embedded('#resource-3', {
    user: "MasseGuillaume",
    base64UUID: "33D4P3ysQCq2em2MRiv5sQ",
    update: 1

Take a look at:

Converting Code Into Snippets

It's also possible to convert code into a snippet. The preferred way is to embed a snippet since it's output is cached. This mode will compile and run the snippet every time it's accessed.

<pre class="simple">
1 + 1

<pre class="scala-js">
import org.scalajs.dom
import org.scalajs.dom.raw.HTMLImageElement

val img = dom.document.createElement("img").asInstanceOf[HTMLImageElement]
img.alt = "such dog" 
img.src = ""

<pre class="full"></pre>

<!-- Embedding Script -->
<script src=""></script>

window.addEventListener('load', function() {
  // DOM selector without build options

  // with some options
  scastie.Embedded('.scala-js', { targetType: 'js' });

  // all option
  scastie.Embedded('.full', {
    theme: 'light', // default: 'light'; ('dark' or 'light')
    code: '1 + 1', // default: DOM node content
    isWorksheetMode: true,
    sbtConfig: 'libraryDependencies += "org.json4s" %% "json4s-native" % "3.5.2"',
    targetType: 'jvm',  // jvm, dotty, typelevel, js
    scalaVersion: '2.12.4'

  // Setting Scala-Native targetType is not yet supported:
  // Setting Scala.js version is not yet supported:

Take a look at:


Scastie is supported by the Scala Center

Scala Center Logo

with the help of Browser Stack for end-to-end testing

Browser Stack Logo