Built-in Module Quick Reference

Table of Contents


Node ships with over 40 built-in modules You don’t need to memorize every API but you need to know what exists so you don’t reinvent the wheel Here’s every core module grouped by category with what it does and when to use it

I/O Modules

ModuleDescriptionKey exportsWhen to use
fsFile system operationsreadFile , writeFile , createReadStream , mkdir , stat , watchEverything file-related
pathPath manipulationjoin , resolve , basename , dirname , extname , parseAlways - never hardcode paths
streamStreaming data APIReadable , Writable , Transform , Duplex , pipelineLarge data , piping between I/O
bufferBinary data handlingBuffer , Buffer.alloc , Buffer.from , Buffer.concatBinary data , network protocols
readlineRead line-by-linecreateInterfaceProcess large text files line by line
string_decoderDecode buffers to stringsStringDecoderProper multi-byte UTF-8 decoding
zlibCompression/decompressiongzip , gunzip , deflate , inflate , brotliCompressCompress HTTP responses , files
cryptoCryptographyrandomBytes , createHash , createHmac , createCipheriv , sign , verifyHashing , encryption , token generation

Network Modules

ModuleDescriptionKey exportsWhen to use
httpHTTP client and servercreateServer , request , getREST APIs , HTTP services
httpsHTTPS client and servercreateServer , request , getSecure HTTP - always use in production
http2HTTP/2 client and servercreateServer , connectgRPC , low-latency APIs
netTCP client and servercreateServer , connectRaw TCP , custom protocols
dnsDNS resolutionlookup , resolve , resolve4 , resolve6 , reverseDomain lookups , email validation
dgramUDP communicationcreateSocketDNS servers , real-time protocols , broadcasting
tlsTLS/SSL encryptioncreateServer , connect , TLSSocketSecure TCP , certificate verification
urlURL parsing and formattingURL , URLSearchParams , parse , formatWorking with URLs (always use URL class)

System Modules

ModuleDescriptionKey exportsWhen to use
osOperating system infocpus , totalmem , freemem , hostname , platform , homedirThread pool sizing , system info
processCurrent process controlargv , env , exit , cpuUsage , memoryUsage , uptimeCLI apps , monitoring
child_processSpawn child processesspawn , exec , execFile , forkRunning external commands
clusterMulti-process load balancingfork , isMaster , isPrimaryScaling HTTP across CPU cores
worker_threadsThread-based parallelismWorker , parentPort , workerData , SharedArrayBufferCPU-intensive work
perf_hooksPerformance measurementperformance , PerformanceObserver , createHistogramProfiling , timing
v8V8 engine accessgetHeapStatistics , setFlagsFromString , serializeMemory debugging , serialization
vmVirtual machine contextcreateContext , runInContext , runInNewContextSandboxed code execution
wasiWebAssembly System InterfaceWASIRust/AssemblyScript in Node
ttyTerminal I/OWriteStream , ReadStream , isattyCLI tools - detect terminal , colors

Data Modules

ModuleDescriptionKey exportsWhen to use
querystringQuery string parsingparse , stringify , escape , unescapeLegacy query parsing (prefer URL)
punycodeUnicode encodingencode , decode , toASCII , toUnicodeInternational domain names
utilGeneral utilitiespromisify , callbackify , types , inspect , inheritsDebugging , type checking
assertTesting assertionsstrict , ok , equal , deepEqual , throws , rejectsWriting tests
eventsEvent systemEventEmitter , once , getEventListenersCustom event-driven code

Control Flow Modules

ModuleDescriptionKey exportsWhen to use
timersDelayed executionsetTimeout , setInterval , setImmediate , queueMicrotaskThrottling , debouncing , scheduling
async_hooksAsync resource trackingcreateHook , executionAsyncId , triggerAsyncIdAdvanced diagnostic , APM tools
diagnostics_channelPub/sub diagnostic channelchannel , subscribe , hasSubscribersCross-module observability

Debug and Tooling Modules

ModuleDescriptionKey exportsWhen to use
reportDiagnostic reportwriteReport , getReport , triggerReportCrash diagnostics , memory analysis
inspectorDebugging protocolopen , close , url , SessionsCustom debugging tools
trace_eventsTrace event instrumentationcreateTracingPerformance analysis
moduleModule system internalsbuiltinModules , Module , createRequire , findSourceMapModule loading customization
consoleDebug outputlog , error , warn , table , time , trace , dirEverything debug

Security-Critical Modules

ModuleKey Security Properties
cryptoUse for hashing (SHA-256+) , encryption (AES-256-GCM) , random bytes
tlsAlways verify certificates , set rejectUnauthorized: true
httpsAlways use https over http in production
vmNOT a security sandbox - code can escape the context
child_processCommand injection via shell - use spawn with arrays
fsPath traversal - validate user-provided paths
netNo built-in encryption - use tls wrapper for sensitive data

Module Loading

// CommonJS (default in Node)
const fs = require('fs')

// ESM (ES Modules)
import fs from 'node:fs'
import { readFile } from 'node:fs/promises'

// Built-in modules use the 'node:' scheme (recommended in ESM)
import { createServer } from 'node:http'

The node: prefix is supported in Node 16+ and makes built-in imports explicit Required: node:fs , optional-style: fs (both work)

Quick Start Import Patterns

// Most commonly used imports
const fs = require('fs')
const fsPromises = require('fs/promises')
const path = require('path')
const { EventEmitter } = require('events')
const { spawn } = require('child_process')
const http = require('http')
const https = require('https')
const crypto = require('crypto')
const os = require('os')
const util = require('util')
const { pipeline } = require('stream/promises')
const { Worker } = require('worker_threads')

Prerequisites

Posted · Updated