Skip to main content
The deno repl command starts an interactive Read-Eval-Print Loop for evaluating JavaScript and TypeScript code.

Usage

deno repl [OPTIONS]
deno  # Starts REPL as default command

Description

The REPL provides an interactive environment to experiment with Deno, evaluate expressions, and test code snippets. It supports TypeScript, top-level await, and has built-in tab completion.

Flags

--eval-file
string
Evaluate a file before entering the REPL. Can be specified multiple times
--eval
string
Evaluate code before entering the REPL
--import-map
string
Load import map file
--no-npm
boolean
Do not resolve npm modules
--node-modules-dir
boolean
Enables or disables the use of a local node_modules folder
--config
string
Specify the configuration file
--no-config
boolean
Disable automatic loading of the configuration file

Permission Flags

By default, when running just deno (REPL as default command), all permissions are allowed. When explicitly running deno repl, you need to specify permissions:
--allow-read
string
Allow file system read access
--allow-write
string
Allow file system write access
--allow-net
string
Allow network access
--allow-env
string
Allow environment access
--allow-run
string
Allow running subprocesses
--allow-all
boolean
Allow all permissions

Features

TypeScript Support

The REPL natively supports TypeScript:
> const greeting: string = "Hello, Deno!";
> console.log(greeting);
Hello, Deno!

Top-level Await

Use await at the top level:
> const response = await fetch("https://api.github.com/users/denoland");
> const data = await response.json();
> data.name
"Deno"

Tab Completion

Press Tab to autocomplete:
> console.l<Tab>
log    
info   
warn   
error  

Special Variables

  • _ - Result of the last evaluated expression
  • _error - Last thrown error
> 2 + 2
4
> _ * 2
8

Multiline Input

Press Shift+Enter for multiline input:
> function greet(name) {<Shift+Enter>
    return `Hello, ${name}!`;<Shift+Enter>
  }<Shift+Enter>
> greet("World")
"Hello, World!"

Examples

Basic REPL

Start the REPL with all permissions:
deno

REPL with specific permissions

deno repl --allow-net --allow-read

Evaluate code on startup

Run code before entering the REPL:
deno repl --eval "const API_URL = 'https://api.example.com'"

Load a file before REPL

Evaluate a file to set up the environment:
deno repl --eval-file setup.ts

Load multiple files

deno repl --eval-file config.ts --eval-file utils.ts

With import map

deno repl --import-map=import_map.json

With configuration file

deno repl --config deno.json

Keyboard Shortcuts

  • Ctrl+C - Exit (press twice) or cancel current input
  • Ctrl+D - Exit
  • Tab - Autocomplete
  • Shift+Enter - Multiline input
  • Up/Down - Navigate command history
  • Ctrl+R - Reverse search history

REPL History

Command history is saved in:
  • Unix: ~/.cache/deno/repl_history.txt
  • Windows: %LOCALAPPDATA%/deno/repl_history.txt
  • macOS: ~/Library/Caches/deno/repl_history.txt

Exit the REPL

You can exit the REPL in several ways:
// Type close() function
> close()

// Press Ctrl+D

// Press Ctrl+C twice

Tips

Import modules

> const { join } = await import("jsr:@std/path");
> join("foo", "bar")
"foo/bar"

Access Deno APIs

> Deno.version
{ deno: "2.1.0", v8: "12.9.202.5", typescript: "5.6.2" }

Quick experiments

Test regular expressions:
> /\d+/.test("hello123")
true
Try out array methods:
> [1, 2, 3, 4, 5].filter(x => x % 2 === 0)
[2, 4]

Build docs developers (and LLMs) love