Online Scala Compiler
Compile and run Scala online with Scala 3.10. Write an @main method or an object with def main, press Run, and scalac compiles it and starts it on Java 17, with compiler errors and output shown beside your code. Programs can read input with StdIn.readLine as they run.
How to run Scala code online
- This page opens with Scala selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
Scala 3.10 on Online IDE
- Your code is compiled with scalac and runs on Java 17, and both braces and Scala 3's indentation syntax work.
- The program starts at its main method: an @main method, or def main(args: Array[String]): Unit in an object such as Main.
- scala.io.StdIn.readLine() reads a line of input, and text you print first shows before the program waits.
- The Scala standard library and the Java class library are available, but sbt and library dependencies are not.
Example: a Scala program that reads input
import scala.io.StdIn
object Main {
def grade(score: Int): String = score match {
case s if s >= 90 => "A"
case s if s >= 80 => "B"
case s if s >= 70 => "C"
case s if s >= 60 => "D"
case _ => "F"
}
def main(args: Array[String]): Unit = {
print("Enter scores separated by spaces: ")
val scores = StdIn.readLine().split(" ").flatMap(_.toIntOption)
for (score <- scores) println(s"$score: ${grade(score)}")
}
}
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Scala version does Online IDE use?
Scala 3.10, compiled with scalac and run on Java 17, on Linux.
Where does my program start?
At its main method: an @main method, or def main(args: Array[String]): Unit in an object, as in the example. If there are several, the one in object Main runs.
How does a Scala program read input?
Call scala.io.StdIn.readLine(), then type into the output panel while the program waits and press Enter. A prompt printed with print shows first.
Can I add library dependencies?
No. There is no sbt build, and programs cannot download libraries. The Scala and Java standard libraries are available.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.