# How to Create and Use the Deno REPL: A Complete Developer Guide

> Learn how to create and use the Deno REPL for interactive TypeScript and JavaScript coding. Execute code, import modules, and access Deno namespace easily.

- Repository: [Deno/deno](https://github.com/denoland/deno)
- Tags: how-to-guide
- Published: 2026-02-26

---

**Launch the Deno REPL by running the `deno` command without arguments, which starts an interactive TypeScript/JavaScript shell with full permissions enabled, allowing immediate execution of code, module imports, and access to the `Deno` namespace.**

The Deno REPL (Read-Eval-Print Loop) provides an interactive environment for experimenting with TypeScript and JavaScript without creating files. According to the denoland/deno source code, understanding how to create and use the Deno REPL involves tracing the CLI argument parsing through to the worker initialization and evaluation loop.

## Starting the Deno REPL

The simplest way to create a Deno REPL session is to invoke the binary without specifying a script file.

```bash
deno

```

When executed without arguments, the Deno CLI detects the absence of a target script and routes execution to the REPL implementation. This behavior is defined in [`cli/args/flags.rs`](https://github.com/denoland/deno/blob/main/cli/args/flags.rs), which handles the argument parsing and identifies when to enter interactive mode.

By default, the REPL starts with **full permissions** (`--allow-all` is automatically applied), removing the need to grant individual permissions for network, file system, or environment access during interactive sessions.

## REPL Architecture and Source Code

Understanding the internal structure of how to create and use the Deno REPL requires examining the worker factory and evaluation loop.

### CLI Entry Point and Flag Parsing

The REPL entry point begins in [`cli/args/flags.rs`](https://github.com/denoland/deno/blob/main/cli/args/flags.rs), where the flag parser defines REPL-specific options including:

- `--eval`: Execute code before entering the REPL
- `--allow-all`: Automatically enabled for REPL sessions
- Environment variable handling for `DENO_REPL_HISTORY`

### Worker Creation and Permissions

The main REPL logic resides in [`cli/tools/repl/mod.rs`](https://github.com/denoland/deno/blob/main/cli/tools/repl/mod.rs). This module creates a `CliMainWorkerFactory` that spins up a main worker with full permissions enabled. Unlike standard script execution, the REPL worker bypasses individual permission prompts to ensure a smooth interactive experience.

### The Evaluation Loop

Inside the worker, the JavaScript side runs the built-in `Deno.core.evalContext` loop. This loop performs the following sequence:

1. Reads a line from standard input
2. Evaluates the code in the global context
3. Prints the result or error to stdout
4. Prompts for the next line

This cycle continues until the user exits the session.

## Command History and Persistence

The Deno REPL maintains command history across sessions, enabling you to recall previous commands using arrow keys.

### Default History Location

History persistence is managed by the `DenoDir` implementation in [`libs/resolver/cache/deno_dir.rs`](https://github.com/denoland/deno/blob/main/libs/resolver/cache/deno_dir.rs). By default, the history file is stored at:

```

$DENO_DIR/repl_history.txt

```

Where `$DENO_DIR` defaults to `$HOME/.cache/deno` on Linux, `$HOME/Library/Caches/deno` on macOS, or `%LOCALAPPDATA%/deno` on Windows.

### Customizing History with DENO_REPL_HISTORY

You can override the default history location or disable history entirely using the `DENO_REPL_HISTORY` environment variable:

```bash

# Use a custom history file

export DENO_REPL_HISTORY="$HOME/.my_deno_history"
deno

```

```bash

# Disable history completely

export DENO_REPL_HISTORY=""
deno

```

## Advanced REPL Usage

Beyond basic interaction, the Deno REPL supports several advanced features for power users.

### Evaluating Code Snippets with --eval

You can execute code immediately upon starting the REPL without entering interactive mode first using the `--eval` flag:

```bash
deno --eval "console.log('Hello from REPL')"

```

This prints the result and then drops you into the REPL prompt, allowing you to continue interacting with the variables and functions defined in the eval snippet.

### Importing Modules in the REPL

The REPL supports dynamic imports, enabling you to load external modules during your session:

```ts
> import { serve } from "https://deno.land/std@0.203.0/http/server.ts";
> serve(() => new Response("Hello"));

```

This creates a server directly from the REPL without creating a local file, demonstrating the full power of Deno's permissionless module loading in interactive mode.

### Exiting the Session

To exit the Deno REPL, use one of the following methods:

- Press **Ctrl+D** (EOF signal)
- Type `.exit` (if the exit command is enabled in your version)
- Press **Ctrl+C** twice (interrupt signal)

## IDE Integration via LSP

When using the Deno REPL through an integrated development environment like VS Code, the Language Server Protocol (LSP) provides enhanced functionality. The LSP server loads [`cli/lsp/repl.rs`](https://github.com/denoland/deno/blob/main/cli/lsp/repl.rs), which forwards LSP-specific diagnostics, completions, and type information to the same REPL worker used in CLI mode.

This integration ensures that editor features like autocomplete and error highlighting work seamlessly within REPL sessions launched from your IDE.

## Summary

- **Launch the REPL** by running `deno` without arguments; the CLI routes to [`cli/tools/repl/mod.rs`](https://github.com/denoland/deno/blob/main/cli/tools/repl/mod.rs) when no script is specified.
- **Full permissions** are automatically granted in REPL mode via `CliMainWorkerFactory` to enable unrestricted experimentation.
- **History persistence** defaults to `$DENO_DIR/repl_history.txt` and can be customized via the `DENO_REPL_HISTORY` environment variable.
- **Advanced features** include `--eval` for startup code execution and dynamic `import()` support for loading remote modules.
- **LSP integration** in [`cli/lsp/repl.rs`](https://github.com/denoland/deno/blob/main/cli/lsp/repl.rs) provides IDE support for interactive sessions.

## Frequently Asked Questions

### How do I start the Deno REPL with specific permissions?

You do not need to specify permissions when starting the Deno REPL. According to the source code in [`cli/tools/repl/mod.rs`](https://github.com/denoland/deno/blob/main/cli/tools/repl/mod.rs), the REPL automatically runs with `--allow-all` permissions enabled through the `CliMainWorkerFactory`. This design choice removes friction during interactive development by granting full access to the file system, network, and environment variables.

### Where is the Deno REPL history stored?

By default, the REPL history is stored at `$DENO_DIR/repl_history.txt`, as implemented in [`libs/resolver/cache/deno_dir.rs`](https://github.com/denoland/deno/blob/main/libs/resolver/cache/deno_dir.rs). The `$DENO_DIR` variable resolves to platform-specific cache directories such as `~/.cache/deno` on Linux or `~/Library/Caches/deno` on macOS. You can override this location or disable history entirely by setting the `DENO_REPL_HISTORY` environment variable.

### Can I import external modules in the Deno REPL?

Yes, the Deno REPL supports dynamic module imports using standard ES module syntax. You can use `import` statements directly at the prompt to load local files or remote URLs, such as `import { serve } from "https://deno.land/std@0.203.0/http/server.ts";`. This functionality works because the REPL worker runs with full permissions and has access to Deno's module resolution system.

### How does the Deno REPL handle TypeScript?

The Deno REPL executes TypeScript code directly without requiring separate compilation steps. When you enter TypeScript syntax at the REPL prompt, the `Deno.core.evalContext` function (running inside the worker created by `CliMainWorkerFactory`) compiles and executes the code immediately. This provides a seamless TypeScript development experience in the interactive shell, identical to running `.ts` files directly with Deno.