Skip to main content

Deno Cheatsheet

Deno is a secure JavaScript and TypeScript runtime built by Node.js creator Ryan Dahl. It features built-in TypeScript compilation, formatting, linting, testing, a secure-by-default permission system, and native support for Web APIs, JSR, and npm packages.

Updated: 2026-07-20·40 commands

Quick Start

``bash # Run a script deno run main.ts

# Run with network access deno run --allow-net main.ts

# Watch mode — auto-restart on changes deno run --watch main.ts

# Format code deno fmt

# Run tests deno test

# Start REPL deno repl

# Evaluate inline code deno eval 'console.log("hello deno")' `

Install & Setup

`bash deno --version # Show version info deno upgrade # Upgrade to latest deno upgrade --version 2.0.0 # Upgrade/downgrade to specific version deno info # Show cache and module resolution info `

Basic Usage

`bash deno run main.ts # Run a file deno run --watch main.ts # Watch mode (auto-restart on file changes) deno eval 'console.log("hi")' # Run inline code deno repl # Start interactive REPL `

Script Management

`bash deno compile --allow-read main.ts # Compile to standalone binary deno compile --target x86_64-unknown-linux-gnu main.ts # Cross-compile deno compile --output dist/cli main.ts # Custom output name deno install -g --allow-net --allow-read https://deno.land/std/http/file_server.ts # Install global script deno uninstall file_server # Uninstall global script deno task dev # Run task from deno.json deno task --watch test # Task watch mode `

Permissions

`bash deno run --allow-read main.ts # Allow file system read deno run --allow-write main.ts # Allow file system write deno run --allow-net main.ts # Allow network access deno run --allow-env main.ts # Allow env variable access deno run --allow-all main.ts # Grant all permissions deno run --allow-read=/data --allow-write=/tmp main.ts # Scope to paths deno run --allow-net --deny-net=api.example.com main.ts # Deny specific hosts `

Package Management

`bash deno add @std/assert # Add JSR dependency deno add npm:express # Add npm dependency deno remove @std/assert # Remove a dependency deno publish # Publish module to JSR deno cache main.ts # Cache remote module dependencies `

Testing & Lint

`bash deno test # Run all tests deno test --watch # Run tests in watch mode deno test --coverage # Run tests with coverage collection deno bench # Run benchmarks deno lint # Lint code for style & errors deno fmt # Format code (built-in formatter) deno check main.ts # Type-check without executing `

Advanced

`bash deno doc mod.ts # Generate documentation deno doc --json mod.ts # Output docs in JSON format deno jupyter --install # Start Jupyter kernel (experimental) deno serve main.ts # Start HTTP server (Fetch API) deno run --v8-flags=--max-old-space-size=2048 main.ts # Set V8 memory deno run --inspect-brk main.ts # Debug (paused at first statement) `

FAQ

### How do I configure Deno?

Create a deno.json or deno.jsonc in your project root. It supports tasks, imports (import map), compiler options, lint/fmt settings, and publish configuration. Example:

`json { "tasks": { "dev": "deno run --watch --allow-net main.ts", "test": "deno test --coverage" }, "imports": { "express": "npm:express@^5.0.0" } } `

### How do I use Web APIs in Deno?

Deno implements browser-compatible Web APIs: fetch, Request, Response, WebSocket, Console, setTimeout, URL, Blob, File, FormData, TextEncoder, ReadableStream, and more. No polyfills needed — they Just Work.

`typescript // Fetch example (needs --allow-net) const res = await fetch('https://api.example.com'); const data = await res.json(); `

### How do I debug Deno scripts?

Use --inspect or --inspect-brk to start the V8 inspector, then connect Chrome DevTools or VS Code debugger:

`bash deno run --inspect-brk main.ts # Open chrome://inspect in Chrome ``

Install & Setup(4)

CommandLevel
deno --version
Show Deno, TypeScript, and V8 engine versions
Basic
deno upgrade
Upgrade Deno to the latest version
Basic
deno upgrade --version 2.0.0
Upgrade or downgrade to a specific version
Intermediate
deno info
Show cache and module resolution info
Basic

Basic Usage(4)

CommandLevel
deno run
Run a TypeScript or JavaScript file
Basic
deno run --watch
Watch mode — auto-restart on file changes
Intermediate
deno eval
Run inline code snippet
Basic
deno repl
Start an interactive REPL session
Basic

Script Management(7)

CommandLevel
deno compile
Compile script into a standalone executable
Intermediate
deno compile --target x86_64-unknown-linux-gnu
Cross-compile for a specific target platform
Expert
deno compile --output dist/cli
Specify output binary name
Intermediate
deno install
Install a remote script as a global command
Intermediate
deno uninstall
Uninstall a previously installed global command
Basic
deno task
Run a task defined in deno.json
Basic
deno task --watch
Run task in watch mode (re-run on changes)
Intermediate

Permissions(7)

CommandLevel
deno run --allow-read
Allow file system read access
Basic
deno run --allow-write
Allow file system write access
Basic
deno run --allow-net
Allow network access
Basic
deno run --allow-all
Grant all permissions (not recommended for production)
Basic
deno run --deny-net=api.example.com
Deny access to specific network addresses
Expert
deno run --allow-env
Allow environment variable access
Basic
deno run --allow-read=/data --allow-write=/tmp
Scope file permissions to specific paths
Intermediate

Package Management(5)

CommandLevel
deno add
Add a JSR or npm package to the project
Basic
deno remove
Remove a dependency from the project
Basic
deno add npm:express
Add an npm-compatible package
Basic
deno publish
Publish a module to JSR
Intermediate
deno cache
Cache remote module dependencies
Intermediate

Testing & Lint(7)

CommandLevel
deno test
Run tests
Basic
deno test --watch
Run tests in watch mode
Intermediate
deno test --coverage
Run tests with coverage collection
Intermediate
deno bench
Run benchmarks
Intermediate
deno lint
Lint code for style and potential errors
Basic
deno fmt
Format code with built-in formatter
Basic
deno check
Type-check code without executing
Intermediate

Advanced(6)

CommandLevel
deno doc
Generate documentation for a module
Intermediate
deno doc --json
Output docs in JSON format
Intermediate
deno jupyter
Start Jupyter Notebook kernel (experimental)
Expert
deno serve
Start an HTTP server using built-in Fetch API
Expert
deno run --v8-flags=--max-old-space-size=2048
Set V8 engine memory limit
Expert
deno run --inspect-brk
Enable debugger, paused at first statement
Expert

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-20.