Count the number of Safari tabs
Summary
A technical tip published on June 29, 2026, details a straightforward method for counting the total number of open browser tabs within Safari using a single AppleScript command. The command, `osascript -e 'tell application "Safari" to count tabs of every window'`, can be executed directly from a terminal window. An illustrative example demonstrated a user with an impressive 370 open tabs, underscoring the common challenge of managing extensive browser tab collections. This simple utility provides Safari users with a quick, programmatic tool to gain immediate insight into their browsing habits and to better manage their open windows, offering an alternative to tedious manual counting or navigation through numerous active tabs. It presents a practical, efficient solution for quantifying current tab usage.
Key takeaway
For software engineers or power users struggling with browser performance due to excessive open tabs, you can quickly quantify your Safari tab load. Use the provided AppleScript command to get an immediate count, like "370", helping you decide when to close windows or implement better tab management strategies. This simple check provides objective data to inform your digital hygiene practices and potentially improve system responsiveness.
Key insights
AppleScript provides a simple command-line method to programmatically count Safari browser tabs.
Principles
- Scripting enables system introspection.
- Automate repetitive browser tasks.
Method
Execute `osascript -e 'tell application "Safari" to count tabs of every window'` in a terminal to get the total count of open Safari tabs across all windows.
In practice
- Monitor personal tab usage.
- Integrate into tab management scripts.
Topics
- AppleScript
- Safari
- Browser Automation
- Tab Management
- Command Line Interface
Best for: Software Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Simon Willison's Weblog.