denodeno-jsontypescriptpackage-jsondevtoolsconfig

Deno 2.x JSON Guide: Mastering deno.json, Imports & Workspace Config

·8 min read·Developer Tools

The evolution of configuration in modern JavaScript

For a decade, the Node.js ecosystem accumulated configuration sprawl: package.json, tsconfig.json, .eslintrc.json, .prettierrc.json, jest.config.js, and turborepo.json all fighting for authority in your root directory.

Deno 2.0 consolidated this fragmentation into a single canonical manifest: `deno.json` (or deno.jsonc if you prefer comments).

With Deno 2's native support for npm packages, Node.js built-ins (node:fs, node:crypto), monorepo workspaces, and built-in linting/formatting, deno.json replaces half a dozen config files with one clean, type-checked JSON document.

The structure of a complete deno.json

A standard deno.json file controls imports, compiler options, tasks, formatting, and monorepo boundaries:

json
{
  "name": "@acme/core-api",
  "version": "2.4.0",
  "exports": "./src/index.ts",
  "tasks": {
    "dev": "deno run --watch --allow-net --allow-env src/main.ts",
    "test": "deno test --coverage",
    "build": "deno compile --output dist/api src/main.ts"
  },
  "imports": {
    "hono": "jsr:@hono/hono@^4.6.0",
    "zod": "npm:zod@^3.24.0",
    "@std/json": "jsr:@std/json@^1.0.0",
    "@/": "./src/"
  },
  "compilerOptions": {
    "strict": true,
    "jsx": "react-jsx",
    "jsxImportSource": "react"
  },
  "fmt": {
    "useTabs": false,
    "lineWidth": 100,
    "indentWidth": 2,
    "singleQuote": false
  },
  "lint": {
    "rules": {
      "tags": ["recommended"]
    }
  }
}

1. Import Maps: Unifying npm, JSR, and path aliases

Instead of maintaining a separate tsconfig.json for path mapping and package.json for dependencies, the "imports" key in deno.json is a standard Web Import Map:

json
{
  "imports": {
    // 1. JSR package (Modern, typed TypeScript registry)
    "@std/http": "jsr:@std/http@^1.0.0",

    // 2. npm package (With automatic type definitions)
    "chalk": "npm:chalk@^5.3.0",

    // 3. Path alias (Like Next.js @/* mapping)
    "@/components/": "./src/components/",
    "@/lib/": "./src/lib/"
  }
}

Now in any TypeScript file:

typescript
import { serve } from "@std/http";
import chalk from "chalk";
import { formatJson } from "@/lib/formatter.ts";

console.log(chalk.green("Server initialized!"));

2. Monorepo Workspaces in Deno 2

Deno 2 introduces native monorepo workspace support. Define the member directories in your root deno.json:

json
{
  "workspace": [
    "./packages/shared-types",
    "./packages/api-gateway",
    "./packages/web-client"
  ]
}

In packages/shared-types/deno.json:

json
{
  "name": "@acme/types",
  "version": "1.0.0",
  "exports": "./index.ts"
}

Now api-gateway and web-client can import @acme/types instantly without symlinks or npm link setup.

3. High-Performance JSON handling with @std/json

Deno's standard library ships with @std/json, providing streaming parsers and NDJSON encoders optimized for low memory usage:

typescript
import { JsonStringifyStream } from "@std/json/stringify-stream";
import { JsonParseStream } from "@std/json/parse-stream";

// Streaming large NDJSON lines without buffering entire files in memory
const file = await Deno.open("./large-dataset.jsonl");

const recordStream = file.readable
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(new JsonParseStream());

for await (const record of recordStream) {
  console.log("Processed Record ID:", (record as any).id);
}

deno.json vs package.json Feature Matrix

Featuredeno.jsonTraditional package.json
Comments SupportSupported via deno.jsoncNo (Forbidden in pure JSON)
Path AliasesBuilt-in via "imports"Requires tsconfig.json
Formatting / Linting RulesNative "fmt" / "lint"Requires Prettier + ESLint files
Workspace SupportNative "workspace" arrayRequires pnpm-workspace.yaml
Task RunnerBuilt-in "tasks""scripts" key

Helpful Tools for Deno Developers

Frequently asked questions

Yes. If you name your file deno.jsonc, Deno natively allows single-line (//) and multi-line (/* */) comments as well as trailing commas.

Yes. Deno 2 has backwards compatibility with package.json. If both files exist, Deno merges them, giving precedence to deno.json.

You can run deno add npm:package-name or deno add jsr:@scope/package-name, which automatically writes the dependency into your deno.json "imports" section.

Yes. The official Deno extension for VS Code automatically provides intellisense, JSON schema validation, and autocompletion for all deno.json properties.

Try JSON Formatter & Schema Validator

Format and validate deno.json and deno.jsonc configuration files with full syntax checking.