Show your console.log inline on Visual Studio Code, Cursor and other editors
β οΈ Beta. Console Lens is under active development β expect rough edges and
breaking changes between versions. Bug reports and feedback are very welcome.
Free, source-available inline runtime insight for VS Code.
See your console.log values, errors, and network requests right next to the
code that produced them, in real time β no breakpoints, no switching to a terminal.
function add(a, b) {
const result = a + b;
console.log('add ->', result); // βΊ add -> 6 Γ3 β appears here, live
return result;
}
console.log results next to the source line, with an ΓN run counter.HH:MM:SS.mmm timestamp.fetch shows method Β· status Β· url inline, payloads on hover (Node + browser).table, dir, assert, count, time, trace, group; rate-limited.Cmd/Ctrl+Alt+L).Ask AI in every hover, plus an MCP server for Copilot/Cursor/Claude/Windsurf/Cline..astro / .tsx / .ts source.A single shared broker process owns the fixed ports and fans every event out
to all editor windows, so any number of windows (and editors) watch the same
runtime at once. The first window to start spawns the broker; the rest detect it
and subscribe instead of starting their own server.
your app (node) broker (shared, 1 process) your editors
ββββββββββββββββββββ TCP ββββββββββββββββββββββ fan-out βββββββββββββββββββ
β agent (preload) β ββββββΊ β LensServer (agents) β βββββββββΊ β window A β β
β β’ patches consoleβ JSON β + browser WS β βββββββββΊ β window B β€ inline
β β’ captures errorsβ β EventLog β βββββββββΊ β Cursor β¦ β + panel
β β’ wraps fetch β β βββ events.json βββββββΊ MCP server βββΊ AI β
β β’ injects browserβ WS ββββββββββββββββββββββ βββββββββββββββββββ
β client (HTML) β βββββ browser (Vite / Astro / Next.js page)
ββββββββββββββββββββ subscribers connect on port + 2
src/shared β pure, dependency-free core (protocol, serialization, stack capture,src/agent β the --require runtime agent: console patching, error capture,fetch wrapping, browser auto-injection. Zero dependencies.src/broker β the shared broker process (LensServer + subscriber fan-out,events.json) and the client editors/viewer use to attach.src/extension β the VS Code extension: broker client, decorations + hovers,src/mcp β standalone stdio MCP server exposing captured runtime data to AI.src/cli β a headless viewer that subscribes to the broker and prints logs.injector/ β the browser client injected into served HTML.npm install
npm run compile
npm run viewer # Terminal 1 β log sink
node --require ./out/agent/preload.js app.js # Terminal 2 β your app
Each log/error/request is echoed in Terminal 1 with its file:line.
midudev.console-lens), a packaged .vsix (npm run reinstall, see below), or~/.console-lens/ + a# >>> Console Lens >>> block). A terminal β or dev server β that was alreadyconsole lens connected Β· http://localhost:<port> Β· browser logs on line (theconsole lens part on a green badge). If you donβt see it, the terminal predatesThe π Console Lens status-bar item opens the panel.
Shell integration is on by default (consoleLens.shellIntegration): the
extension copies the agent to a stable path (~/.console-lens/) and adds
NODE_OPTIONS exports to your shell profile inside # >>> Console Lens >>> fences,
so every Node process you start anywhere streams to the editor. Turn it off with the
setting (it self-removes) or via Console Lens: Disable for all terminals.
Global
NODE_OPTIONSmeans the agent loads into every Node process. Itβs
fire-and-forget: when the editor isnβt listening, logs are dropped and nothing
hangs. For a one-off instead, use Console Lens: Copy NODE_OPTIONS.
Uncaught exceptions (and unhandled rejections that crash) are captured via
uncaughtExceptionMonitor β crash behaviour is unchanged. The error shows inline
in red at every user frame, and the hover lists the full stack (fn @ file:line)
with the source line, plus an Ask AI action.
The agent wraps fetch in Node and the browser without consuming your response (it
reads a clone). Each request shows inline at its call site:
const res = await fetch('/api/echo', { method: 'POST', β¦ }); β 200 POST /api/echo
Blue for 2xx/3xx, red for 4xx/5xx/failures. The hover shows method, URL, status,
duration, and the request and response payloads.
Put the cursor on a line and press Cmd+Alt+L (macOS) / Ctrl+Alt+L to
toggle a logpoint there, or right-click β Console Lens: Add logpoint. Type an
expression (defaults to the selected text / word under the cursor) and Console Lens
evaluates it at that line and shows the value inline β your source file is never
modified.
Scope: framework SSR templates that the framework compiles itself (Astro
frontmatter, Next.js server components) arenβt instrumented by the agent β those
would need a build plugin. Browser/client code and plain Node code are covered.
Click π Console Lens in the status bar (or run Console Lens: Open panel) to
open a viewer of everything captured: a chronological, color-coded, filterable list
on the left and a details pane on the right with Go to and Ask AI buttons.
Console Lens ships an MCP server so your AI agent can read runtime data:
| Tool | Description |
|---|---|
runtime-logs |
Recent console logs |
runtime-errors |
Runtime errors with stack traces |
runtime-logs-and-errors |
Both, in order |
runtime-logs-by-location |
Logs/errors/network for a file (and optional line) |
The extension keeps ~/.console-lens/events.json up to date; the stdio server
(~/.console-lens/out/mcp/server.js) reads it β zero extra dependencies.
Ready-to-run examples for Vite, Astro and Next.js live in
examples/ β each captures server (Node) and browser logs, errors and
network with zero config. See examples/README.md.
npm run viewer
cd examples/vite && npm install && npm run dev:lens
# β β
console lens connected Β· http://localhost:5173 Β· browser logs on
| Command | Description |
|---|---|
Console Lens: Open panel (logs & errors) |
Open the viewer (also the status-bar action) |
Console Lens: Toggle On/Off |
Show/hide inline output |
Console Lens: Pause/Resume capture |
Stop/start collecting events without losing whatβs captured |
Console Lens: Clear All Inline Logs |
Clear decorations, panel and event log |
Console Lens: Export logs to a file |
Save the captured logs/errors/network to a file |
Console Lens: Add/Toggle logpoint on this line |
Add, edit or toggle a logpoint (Cmd/Ctrl+Alt+L) |
Console Lens: Copy MCP config⦠|
Copy the MCP server config for other AI clients |
Console Lens: Enable / Disable for all terminals |
Add/remove the shell integration |
Console Lens: Inject into active terminal |
Wire up an already-open terminal |
Console Lens: Copy NODE_OPTIONS⦠|
Copy the agent flag for a one-off command |
Console Lens: Clean up |
Remove the shell integration & cache now (uninstall does this automatically) |
| Setting | Default | Description |
|---|---|---|
consoleLens.port |
9111 |
Preferred TCP port (browser WS uses port + 1) |
consoleLens.enabled |
true |
Show inline output |
consoleLens.maxInlineLength |
200 |
Max characters shown inline |
consoleLens.shellIntegration |
true |
Make it work in every terminal (edits your shell profile) |
consoleLens.autoAttachTerminals |
true |
Also export into VS Code integrated terminals directly |
Multiple windows / editors: all windows share one broker on
consoleLens.port(the first to start spawns it; the rest detect and reuse it),
so logs reach every open window β even across editors (e.g. VS Code + Cursor) β
and thereβs noEADDRINUSE. KeepconsoleLens.portthe same across windows so
they meet on the same broker; if that port is occupied by an unrelated process,
set it to a free one.
npm run compile # type-check + emit to out/
npm run bundle # bundle the extension (esbuild) into out/extension/index.js
npm run package # produce console-lens-<version>.vsix
npm run reinstall # package AND (re)install into VS Code β use this to test changes
npm test # unit + TCP server + end-to-end agent integration tests
After npm run reinstall, reload VS Code (Cmd+Shift+P β Developer: Reload Window).
Uninstalling is automatic. Removing the extension β the Marketplace
Uninstall button or code --uninstall-extension midudev.console-lens β
runs a vscode:uninstall hook that, on the next restart, strips the shell-profile
block and deletes the ~/.console-lens/ cache for you (the hook skips this during
an update). Nothing to clean up by hand. To undo it sooner, or without
uninstalling, run Console Lens: Clean up.
Server-side logs are source-map resolved: the agent enables Nodeβs source-map
support, so logs in compiled/transpiled code map to your original source (Astro
frontmatter β index.astro, Next.js server components β page.tsx, TS via
tsx/ts-node β .ts). Virtual bundler paths (e.g. webpack://app/page.tsx) are
resolved to the real file on disk.
fetch, XMLHttpRequest and WebSocket (lifecycle) infetch in Node. Node http.request isnβt wrapped yet.This project is licensed under the GNU Affero General Public License v3.0
with the Commons Clause restriction.
You may view, use, modify and contribute to this project, but you may not
sell, offer as a paid SaaS, or commercially exploit a fork or derivative
whose value derives substantially from this software.
Any contribution submitted to this repository is licensed under the same
license terms. See LICENSE for the full text and
CONTRIBUTING.md for how to contribute.