Skip to content
| Marketplace
Sign in
Visual Studio Code>Debuggers>Data SnapshotNew to Visual Studio Code? Get it now.
Data Snapshot

Data Snapshot

Eytan Krief

|
2 installs
| (0) | Free
Capture variable snapshots while debugging and stub them inline to skip slow operations on re-run
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Data Snapshot

Capture debug snapshots of variable values while paused in the debugger, and optionally stub them inline in source so you can run without re-executing slow operations.

Data Snapshot: capture variable and apply stub

Features

Capture variable snapshot

  • When: While debugging, with the debugger paused (e.g. at a breakpoint).
  • How: Select a variable or property access in the editor (e.g. listings or order.items), then:
    • Use the Capture button in the Debug toolbar, or
    • Right‑click → Data Snapshot: Capture Selected Variable (under the debug group).
  • Destructuring: If the current line is a flat destructuring declaration (const { a, b } = … or const [x, y] = …), select one of the binding names (or a pattern that matches the line) to capture every listed binding in one snapshot. Each binding becomes a key under variables in the saved JSON.
  • What it does:
    • Serializes the selected expression's value from the current stack frame (or evaluates a synthetic object for destructuring captures).
    • Uses a fast path when possible: runs JSON.stringify inside the debuggee (Node.js) and reads the result in one round-trip. Handles circular refs, functions, and BigInt.
    • Fallback: Recursive DAP variable fetching with configurable max depth and concurrency limits.
    • Saves a snapshot under .snapshots/snapshots/ with a name like functionName_expression_timestamp.json.
  • Limits: No raw object/array literals as the top-level selection except when matching a supported destructuring line; no nested destructuring patterns in the parser.

Snapshots view

  • Location: Activity bar → Data Snapshot → Snapshots.
  • List: All .json snapshots in .snapshots/snapshots/, newest first.
  • Open: Click a snapshot to open its JSON file in the editor.
  • Rename: Right‑click → Data Snapshot: Rename Snapshot (safe filename; .json is added automatically).
  • Delete: Right‑click → Data Snapshot: Delete Snapshot.
  • Attach to variable: Right‑click → Data Snapshot: Attach Snapshot to Variable (select the variable name in the editor first; skips the snapshot picker for that file).
  • Delete All: Use the view title context menu → Data Snapshot: Delete All Snapshots.

Inline stubs (run without re-executing)

  • Apply stub: After a capture, the extension replaces the declaration for the captured variable(s) in the source file with code that reads the snapshot and assigns the captured value. When you run (without debugging), that variable gets the captured data instead of executing the slow call. Multi-line declarations are replaced as a whole block; the original text is kept inside stub markers for revert.
  • Attach without re-capturing: Use Attach Snapshot to Variable with a variable name selected in the editor to point an existing snapshot file at that declaration (same stub shape as after capture). If you rename a snapshot file, inline stubs that still reference the old path must be updated (remove the stub and attach again, or edit the path).
  • Scope: Rewrites the variable's declaration in the file where the stub is applied, so all callers — in the same file or elsewhere — automatically use the stubbed value.
  • Multiple declarations: If the same variable is declared in several places, a quick pick lets you choose which line to stub.
  • Revert: Use Data Snapshot: Remove Stub… to pick one stub to remove, or Data Snapshot: Remove All Stubs to revert every stub block (marked with // data-snapshot-stub-start / // data-snapshot-stub-end) under src.

Configuration

Setting Type Default Description
data-snapshot.maxDepth number 5 Maximum recursion depth when serializing nested variables (DAP fallback).

Commands

Command Description
Data Snapshot: Capture Selected Variable Capture the selected expression (debugger paused).
Data Snapshot: Attach Snapshot to Variable Apply an existing snapshot to a selected variable name; optional snapshot/key quick picks.
Data Snapshot: Rename Snapshot Rename a snapshot file (Snapshots view context menu).
Data Snapshot: Delete Snapshot Delete one snapshot (Snapshots view context menu).
Data Snapshot: Delete All Snapshots Delete every snapshot (Snapshots view title menu).
Data Snapshot: Remove Stub… Revert one inline stub under src via quick pick.
Data Snapshot: Remove All Stubs Revert all inline stubs in src/**/*.{ts,tsx,js,jsx}.

Activation

The extension activates when you start a debug session (onDebug). After it has loaded, commands such as Attach Snapshot to Variable and Rename Snapshot can be used without the debugger running. Capture still requires a paused debug session.

See CHANGELOG.md for version history.

Created by Eytan Krief, Backend Engineer.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft