VS Code extension
Contents
The PostHog VS Code extension brings feature flags, experiments, event analytics, and session replay data directly into your editor. It works with JavaScript, TypeScript, Go and Ruby files (.js, .jsx, .ts, .tsx, .go, .rb).
With it, you can see live analytics data inline in your code, manage feature flags without leaving your editor, clean up stale flags with AST-based refactoring, and jump to session replays for events in your codebase.
Note: This extension is different from the PostHog MCP server for VS Code, which enables AI agents and Copilot to interact with PostHog. The VS Code extension provides direct, visual tooling for developers in the editor. They complement each other.
Installation
Install directly from your editor:
Or install manually:
- Open the Extensions panel (
Cmd+Shift+Xon Mac,Ctrl+Shift+Xon Windows/Linux) - Search for "PostHog"
- Click Install
The extension is also available on the VS Code Marketplace and the Open VSX Registry.

Requirements:
- VS Code 1.109.0 or later
- A PostHog account
Authentication
Once installed, authenticate the extension with your PostHog account:
- Open the command palette (
Cmd+Shift+P/Ctrl+Shift+P) - Run
PostHog: Sign In - Click the sign-in button — this opens PostHog in your browser where you authenticate via OAuth
- Once authenticated, run PostHog: Select Project to choose which project to connect to
After authenticating, the status bar at the bottom of VS Code shows your active project and last sync time.

Quick start
Once connected, the extension immediately starts analyzing your code:
- SDK initialization diagnostics help you verify that your PostHog
init()calls are configured correctly, surfacing warnings if something looks off - Inline decorations appear next to
posthog.capture()calls showing 7-day event volume sparklines - Feature flag status indicators show next to
posthog.isFeatureEnabled()andposthog.getFeatureFlag()calls - CodeLens actions appear above flag and capture calls with contextual links
- The sidebar populates with your feature flags, experiments, and saved insights

For details on each feature, see:
| Feature | Description |
|---|---|
| Inline code intelligence | Sparklines, flag status, autocomplete, and more |
| Sidebar dashboard | Flags, experiments, analytics, and X-ray tabs |
| Flag management | Toggle, edit, create, and generate types for flags |
| Stale flag cleanup | Find and remove outdated flag checks |
| Session replay | See session and user counts, jump to replays |
Team configuration
Share extension settings across your team by committing a .posthog.json file to your repository root:
This ensures everyone on the team connects to the correct project and the extension recognizes your custom PostHog client variable names and flag wrapper functions.
Multi-project workspaces
If your VS Code workspace contains multiple folders connected to different PostHog projects, the extension detects this automatically. Each folder can have its own .posthog.json with a different projectId. The extension switches context as you navigate between files in different folders.
Set posthog.multiProjectNotifications to true (default) to get notified when the active project changes.
Automatic sync
The extension periodically refreshes its cache of feature flags, experiments, and event data from PostHog. The status bar shows when the last sync occurred. You can also manually refresh with the PostHog: Refresh Feature Flags command.
Configuration reference
| Setting | Description | Default |
|---|---|---|
posthog.additionalClientNames | Additional variable names the extension should recognize as instances of PostHog clients (e.g., ["analytics", "ph"]) | [] |
posthog.additionalFlagFunctions | Additional bare function names that accept a flag key as the first argument (e.g., ["useMyFlag"]) | [] |
posthog.detectNestedClients | Detect PostHog clients accessed via nested member expressions like window.posthog?.capture() | true |
posthog.showInlineDecorations | Show inline annotations (sparklines, flag status) in the editor | true |
posthog.inlineHintsMode | When to show inline hints: always or currentLine | always |
posthog.staleFlagAgeDays | Minimum number of days before a fully rolled out flag is considered stale | 30 |
posthog.staleFlagExcludePatterns | Glob patterns for files and directories to exclude from stale flag scanning | [] |
posthog.useWorkspaceConfig | Load configuration from a .posthog.json file in the workspace root | true |
posthog.multiProjectNotifications | Show notifications when switching between projects in a multi-project workspace | true |
Commands reference
Open the command palette (Cmd+Shift+P / Ctrl+Shift+P) and type "PostHog" to see all available commands.
Authentication and setup
| Command | Description |
|---|---|
PostHog: Sign In | Authenticate with your PostHog personal API key |
PostHog: Sign Out | Disconnect from PostHog |
PostHog: Select Project | Choose which PostHog project to use |
PostHog: Run Setup Wizard | Guided setup for first-time configuration |
Feature flags
| Command | Description |
|---|---|
PostHog: Refresh Feature Flags | Fetch the latest flags from PostHog |
PostHog: Create Feature Flag | Create a new flag in PostHog |
PostHog: Copy Flag Key | Copy a flag key to the clipboard |
PostHog: Show Flag Detail | Open the detail panel for a flag |
PostHog: Open in PostHog | Open the flag or experiment in your browser |
PostHog: Find Flag References | Search the workspace for all usages of a flag key |
PostHog: Generate Flag Types | Generate TypeScript types for all flag payloads |
PostHog: Generate Type | Generate a TypeScript type for a single flag (context menu) |
Experiments
| Command | Description |
|---|---|
PostHog: Show Experiment Detail | Open the detail panel for an experiment |
Session replay
| Command | Description |
|---|---|
PostHog: Watch Sessions | View sessions for an event in your browser |
Stale flags
| Command | Description |
|---|---|
PostHog: Scan for Stale Flags | Scan the workspace for stale feature flag references |
PostHog: Clean Up Stale Flag | Remove a stale flag check from the code |
Further reading
- PostHog VS Code extension on GitHub
- PostHog MCP server for VS Code — AI agent integration
- Feature flags documentation