llms.txt: machine-readable documentation index. Markdown version of this page is also available.

IntelliJ IDEA 2026.2 Help

Run Kotlin interactively

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.

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.

Create a scratch

  • In the main menu, go to File | New | Scratch File or press Ctrl+Alt+Shift+Insert, then select Kotlin.

Run a scratch

  • In the top-left corner of the editor, click the Run button or press Ctrl+Alt+W.

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 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.

11 September 2026