# Run Kotlin interactively

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/idea/llms.txt).

> **TL;DR**
> Required plugin: Kotlin (bundled)

IntelliJ IDEA provides several ways to execute code snippets outside a project. This is useful when you need to quickly evaluate some code fragment, test some scenario, or prototype an improvement. Learn more in the [Kotlin documentation](https://kotlinlang.org/docs/run-code-snippets.html).

## Scratches

Scratch files allow you to create a temporary file to execute your Kotlin code straight away. You don't need to declare a `main` function to execute the statements. They also support syntax highlighting, auto-completion, and other IntelliJ IDEA code editing features. This is useful for testing and prototyping purposes.

Scratches are independent of projects. They can be accessed from any project, but you have to specify where to look for the classes in case you are using project-specific classes.

Procedure: Create a scratch

* In the main menu, go to `File | New | Scratch File` or press `Ctrl+Alt+Shift+Insert` (Windows), `⌘ ⇧ N` (macOS), `⌃ ⇧ N` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ N` (macOS System Shortcuts), `Ctrl+Alt+Shift+Insert` (XWin), `Ctrl+Alt+Shift+Insert` (GNOME), `Ctrl+Alt+Shift+Insert` (KDE), `Ctrl+Alt+Shift+Insert` (Emacs), `Ctrl+Alt+Shift+Insert` (Sublime Text), `⌘ ⇧ N` (Sublime Text (macOS)), `Ctrl+Alt+Shift+Insert` (NetBeans), `Ctrl+Alt+Shift+Insert` (Visual Studio), `⌘ ⇧ N` (Visual Studio (macOS)), `Ctrl+Alt+Shift+Insert` (Eclipse), `⌘ ⇧ N` (Eclipse (macOS)), then select Kotlin.

Procedure: Run a scratch

* In the top-left corner of the editor, click ![the Run button](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.gutter.run.svg) or press `Ctrl+Alt+W` (Windows), `⌘ ⌥ W` (macOS), `⌘ ⌥ W` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ W` (macOS System Shortcuts), `Ctrl+Alt+W` (XWin), `Ctrl+Alt+W` (GNOME), `Ctrl+Alt+W` (KDE), `Ctrl+Alt+W` (Emacs), `Ctrl+Alt+W` (Sublime Text), `⌘ ⌥ W` (Sublime Text (macOS)), `Ctrl+Alt+W` (NetBeans), `Ctrl+Alt+W` (Visual Studio), `⌘ ⌥ W` (Visual Studio (macOS)), `Ctrl+Alt+W` (Eclipse), `⌘ ⌥ W` (Eclipse (macOS)).

You can find the existing scratch files in the `Scratches and Consoles | Scratches` folder.

The following options are available for running Kotlin scratches:

* Use classpath of module (only applicable for scratches): specifies the module with your custom classes if you want to use them in a scratch.

* Interactive mode: runs the code each time you stop typing.

## Kotlin Playground

[Kotlin Playground](https://play.kotlinlang.org/) lets you write, run, and share Kotlin code in a web browser.

Use Kotlin Playground when you want to:

* Try a self-contained code example without creating a project.

* Switch between Kotlin versions and supported execution environment.

* Share a runnable example through a link.

