ConsoleSense 🔍
Real-time console.log preview and intelligent debugging assistant for Visual Studio Code
Stop switching between your editor and browser console. ConsoleSense brings console output directly into your code editor with intelligent hover previews, inline output visualization, and smart navigation features.

✨ Features
🎯 Hover Preview
Hover over any console.log()
statement to instantly see what it will output - actually evaluated, not just variable names!
const name = "Alice";
const age = 25;
console.log(name + " is " + age); // Hover → Shows: "Alice is 25" ✅
👻 Inline Ghost Text
Enable inline previews to see evaluated results right next to your console statements as you type.
const score = 85;
console.log(score * 1.2); // → 102 (appears as ghost text)
🎯 Go To Definition
Click on variables inside console.log statements to jump directly to their declarations - no intermediate menus!
const user = { name: "Bob" }; // ← Jumps here
console.log(user); // Cmd+Click "user"
📊 Console Table Visualizer
Hover over console.table()
to see beautiful formatted tables, or open a full webview panel.
const users = [
{ name: "Alice", age: 25, role: "Developer" },
{ name: "Bob", age: 30, role: "Designer" }
];
console.table(users); // Hover → See formatted table!
📺 Live Console Panel
View all console statements in your current file in a sidebar panel with real-time evaluated output.
- Click any entry to jump to that line
- See evaluated output for each log
- Updates automatically as you type
- Color-coded by console method
📊 Workspace Statistics
Analyze your entire project to find and manage console statements.
- See which files have the most console statements
- Export statistics to CSV
- Visual breakdown by console method
- One-click navigation to files
🧹 Smart Analysis
- Duplicate Detection: Identifies repeated console.log statements
- Empty Log Warning: Flags console.logs with no content
- Production Code Alerts: Warns about logs in production paths
- Quick Cleanup: Remove all console statements with one command
🚀 Installation
From Source (Development)
- Clone and setup:
git clone https://github.com/raredevv/console-sense.git
cd console-sense
npm install
- Install type definitions:
npm install --save-dev @types/babel__traverse @types/babel__core
- Compile TypeScript:
npm run compile
- Run in VS Code:
- Press
F5
to open Extension Development Host
- Open a JavaScript/TypeScript file
- Hover over console.log statements to see previews!
From VSIX Package
- Package the extension:
npm install -g @vscode/vsce
vsce package
- Install in VS Code:
- Go to Extensions view (
Cmd+Shift+X
/ Ctrl+Shift+X
)
- Click
...
→ Install from VSIX
- Select
console-sense-0.0.1.vsix
⚙️ Configuration
Open VS Code Settings (Cmd+,
/ Ctrl+,
) and search for "ConsoleSense":
Setting |
Type |
Default |
Description |
consoleSense.enableHoverPreview |
boolean |
true |
Enable hover preview for console statements |
consoleSense.enableInlinePreview |
boolean |
false |
Show inline ghost text with output |
consoleSense.enableTableVisualization |
boolean |
true |
Enable console.table() visualization |
consoleSense.enableLiveConsole |
boolean |
true |
Enable live console panel in sidebar |
consoleSense.enableDiagnostics |
boolean |
true |
Show diagnostics for issues |
consoleSense.maxHoverPreviewItems |
number |
10 |
Max items in hover preview |
🎮 Commands
Access via Command Palette (Cmd+Shift+P
/ Ctrl+Shift+P
):
Command |
Description |
ConsoleSense: Preview Console Output |
Show preview panel |
ConsoleSense: Toggle Inline Preview |
Enable/disable inline ghost text |
ConsoleSense: Count Console Statements |
Count logs in current file |
ConsoleSense: Remove All Console Statements |
Remove all logs (with confirmation) |
ConsoleSense: Show Table Visualization |
Open console.table in webview |
ConsoleSense: Focus Live Console |
Open live console sidebar |
ConsoleSense: Analyze Workspace |
Scan entire project |
ConsoleSense: Show Statistics |
Open statistics panel |
ConsoleSense: Export Statistics to CSV |
Export analysis to CSV |
💡 Usage Examples
Basic Evaluation
// ✅ Variables resolved correctly
const greeting = "Hello World";
console.log(greeting); // Hover → "Hello World"
// ✅ Expressions actually evaluated
const price = 29.99;
console.log(price * 2); // Hover → 59.98 (NOT "price * 2")
// ✅ Template literals work
const name = "Alice";
console.log(`Hello ${name}!`); // Hover → "Hello Alice!"
Objects and Arrays
// ✅ Object inspection
const user = { name: "Alice", age: 30 };
console.log(user); // Hover → { name: "Alice", age: 30 }
// ✅ Array operations
const numbers = [1, 2, 3, 4, 5];
console.log(numbers.length); // Hover → 5
console.log(numbers[0] * 10); // Hover → 10
Complex Expressions
const items = [
{ name: "Book", price: 20 },
{ name: "Pen", price: 5 }
];
console.log(items[0].name); // Hover → "Book"
console.log(items[0].price * 2); // Hover → 40
🔧 How It Works
ConsoleSense uses several technologies:
- @babel/parser - Parses JavaScript/TypeScript code into an AST
- @babel/traverse - Traverses AST to find console statements
- vm2 - Safely evaluates expressions in a sandboxed environment
- VS Code API - Provides hover, decoration, and navigation features
What Works ✅
- Simple variables:
const x = 5; console.log(x);
- Objects and arrays:
const obj = {a: 1}; console.log(obj);
- Expressions:
console.log(x + y * 2);
- Array/object access:
console.log(arr[0], obj.name);
- Template literals:
console.log(`Hello ${name}`);
- Mathematical operations:
console.log(Math.max(1, 2, 3));
- Boolean logic:
console.log(true && false);
What Doesn't Work ❌
- Imported variables:
import {x} from './file';
- API responses:
fetch().then(r => console.log(r));
- Async operations:
await somePromise
- Functions with side effects
- Browser/Node globals:
console.log(window, process)
- Hover: Instant response
- Inline Preview: 500ms debounce for smooth editing
- Live Console: Updates every 500ms
- Workspace Scan: Processes ~100 files/second
- Memory: <50MB for typical projects
🐛 Troubleshooting
Variables showing as undefined
Solution: Make sure variables are declared BEFORE the console.log statement in the same file.
console.table() not detected
Solution: Ensure proper syntax: console.table(variable)
- avoid complex expressions.
Go-to-definition not working
Solution: The variable must be declared in the same file (imported variables not supported yet).
🔮 Future Features
- [ ] Multi-file Analysis: Track variables across imports
- [ ] TypeScript Type Inference: Show type information
- [ ] AI Explanations: Natural language explanations of logs
- [ ] Smart Suggestions: Recommend better logging practices
- [ ] Performance Metrics: Track console.log performance impact
- [ ] Breakpoint Integration: Set breakpoints from console panel
- [ ] Custom Themes: Customize colors and styles
🤝 Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
)
- Commit your changes (
git commit -m 'Add amazing feature'
)
- Push to the branch (
git push origin feature/amazing-feature
)
- Open a Pull Request
📝 License
MIT License - see LICENSE file for details
🙏 Acknowledgments
📞 Support
Found a bug? Have a feature request?
🎯 Quick Start
- Install the extension
- Open a JS/TS file
- Hover over a console.log → See the magic! ✨
- Press
Cmd+Shift+P
→ Try "Toggle Inline Preview"
- Check the sidebar → Find "Live Console" panel
Happy Debugging! 🚀
Made with ❤️ for developers who love clean, efficient debugging