Browser DevTools: The Complete Guide for JavaScript Developers
The browser DevTools is your most important development tool. You will spend more time in DevTools than in any documentation site. Every professional JavaScript developer uses it constantly — for debugging, inspecting, profiling, and experimenting. This lesson covers everything you need to know.
Opening DevTools
These shortcuts work in Chrome, Edge, and most Chromium-based browsers:
- F12 — toggles DevTools open/closed
- Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (Mac) — same thing
- Ctrl+Shift+J (Windows/Linux) or Cmd+Option+J (Mac) — opens DevTools directly to the Console
- Right-click any element → Inspect — opens DevTools focused on that element
You can dock DevTools to the right, bottom, or left of your browser, or pop it into a separate window. Use whichever feels most comfortable — most developers dock to the right or bottom.
The Console tab
The Console is where you interact with JavaScript directly. Think of it as a live JavaScript playground connected to the current page.
Running JavaScript live
Type any JavaScript expression and press Enter. It executes immediately in the context of the current page:
// Try these in the console on any website
document.title // see the page title
document.querySelectorAll('a').length // count all links
window.location.href // current URL
document.body.style.background = 'red' // turn the page red (temporary!)
Multi-line code
Press Shift+Enter to write multiple lines without executing. This lets you write functions and loops:
// Press Shift+Enter after each line, then Enter on the last
function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
fibonacci(10) // 55
Special console variables
DevTools provides special variables that only work in the console:
$0 // the element currently selected in the Elements tab
$1 // the previously selected element
$_ // result of the last expression you evaluated
$$('div') // shortcut for document.querySelectorAll('div')
$('div') // shortcut for document.querySelector('div')
copy(obj) // copy any value to the clipboard as a string
clear() // clear the console
Console filtering
Click the filter icons at the top of the Console to show/hide different message types (logs, warnings, errors, info). When debugging a busy page, filter for Errors only to find the important messages.
The Elements tab
The Elements tab shows the live DOM tree — the HTML structure of the current page, exactly as the browser sees it (including any changes made by JavaScript).
Inspecting elements
Click the selector icon (top-left corner of DevTools, or press Ctrl+Shift+C) to enter "inspect mode." Now hover over any element on the page to highlight it and see its properties. Click to select it.
Editing HTML live
Double-click any element in the Elements panel to edit its text, attributes, or HTML. Changes are temporary — they revert when you reload. This is incredibly useful for testing layout changes or debugging content issues.
Editing CSS live
In the Styles panel (right side of Elements), you can:
- Click any CSS value to edit it
- Click the empty space to add new properties
- Uncheck the checkbox next to any property to disable it
- Click
+ (New Style Rule)to add a brand new CSS rule
This is the fastest way to experiment with CSS. Make changes live, see the result instantly, then copy the CSS you like into your actual stylesheet.
The box model
The "Computed" tab shows the box model — margin, border, padding, and content dimensions — as a visual diagram. Hover over any section to see it highlighted on the page. This is essential for debugging layout problems.
The Sources tab (debugger)
The Sources tab is where you debug JavaScript. This is the most powerful feature of DevTools and the one that separates beginners from intermediate developers.
Setting breakpoints
A breakpoint pauses your code at a specific line so you can inspect what is happening:
- Open the Sources tab
- Find your JavaScript file in the left sidebar (under Page or File Navigator)
- Click the line number where you want to pause
- A blue marker appears — that is your breakpoint
- Now trigger the code (click a button, reload the page, etc.)
- Execution pauses at that line
What you can do while paused
When execution is paused at a breakpoint, you have full power:
- Hover over any variable to see its current value
- Scope panel (right side) shows all variables in the current scope
- Watch panel — add expressions you want to monitor (e.g.,
user.name,array.length) - Call Stack panel — see the chain of function calls that led to this point
- Console — type any expression to evaluate it in the current scope
Stepping through code
The toolbar at the top of Sources has stepping controls:
- Resume (F8) — continue running until the next breakpoint
- Step Over (F10) — execute the current line and move to the next. If the line calls a function, run the entire function without stepping into it.
- Step Into (F11) — if the current line calls a function, jump inside that function
- Step Out (Shift+F11) — run the rest of the current function and pause at the caller
The debugger statement
Instead of manually setting breakpoints, you can write debugger; directly in your code:
function processData(data) {
debugger; // execution pauses here when DevTools is open
const result = data.map(item => item.value * 2);
return result;
}
Important: debugger only works when DevTools is open. If DevTools is closed, the statement is ignored. Always remove debugger statements before deploying to production.
Conditional breakpoints
Right-click a line number and choose "Add conditional breakpoint." The code only pauses if your condition is true. This is invaluable when debugging loops:
// Instead of breaking on every iteration, only break when i === 50
for (let i = 0; i < 1000; i++) {
processItem(items[i]); // set conditional breakpoint: i === 50
}
Logpoints
Right-click a line number and choose "Add logpoint." This logs a message to the console without pausing execution and without modifying your code. Think of it as a temporary console.log that you do not have to remember to remove.
The Network tab
The Network tab records every HTTP request the page makes — HTML, CSS, JavaScript, images, API calls, everything.
Key columns
- Name — the URL of the request
- Status — HTTP status code (200 = OK, 404 = not found, 500 = server error)
- Type — document, script, xhr/fetch, image, etc.
- Size — how much data was transferred
- Time — how long the request took
Filtering requests
Use the filter buttons (All, Fetch/XHR, JS, CSS, Img, etc.) to narrow down what you see. When debugging API calls, click Fetch/XHR to only see API requests.
Inspecting a request
Click any request to see its details:
- Headers — request and response headers, including cookies and authorization
- Preview — formatted response body (great for JSON APIs)
- Response — raw response body
- Timing — detailed waterfall showing DNS, connection, SSL, waiting, download times
Throttling
The Network tab has a throttling dropdown that simulates slow connections (3G, slow 4G). Use this to test how your site performs on mobile networks — a critical practice for real-world development.
The Application tab
This tab shows all client-side storage:
- localStorage — persistent key-value storage
- sessionStorage — per-tab storage that clears when the tab closes
- Cookies — small pieces of data sent with every request
- IndexedDB — a full database in the browser
- Cache Storage — used by Service Workers for offline functionality
You can view, edit, and delete any stored data directly in this panel. This is essential for debugging authentication (check if tokens are stored correctly), preferences, and cached data.
Performance profiling
The Performance tab records what your page is doing over time — which functions run, how long they take, when the browser paints, and where bottlenecks are.
To use it:
- Click the Record button (or press
Ctrl+E) - Interact with your page (the thing you want to profile)
- Click Stop
- Analyze the flame chart — tall columns = expensive operations
Performance profiling is an advanced skill, but knowing it exists and how to start a recording will put you ahead of most junior developers.
DevTools shortcuts you should memorize
F12 — toggle DevTools
Ctrl+Shift+C — element picker mode
Ctrl+Shift+J — open Console directly
Ctrl+P — open file by name (in Sources)
Ctrl+Shift+P — command palette (like VS Code)
Ctrl+F — search in current panel
Esc — toggle Console drawer (visible from any tab)
A real debugging workflow
Here is how a professional developer typically debugs a problem:
- Reproduce the bug with DevTools open
- Check the Console for errors (red messages)
- If it is a network issue, check the Network tab for failed requests
- If it is a logic bug, set a breakpoint in the Sources tab near where you think the problem is
- Step through the code line by line, watching variable values
- Once you find the bug, fix it in your editor and reload
This process gets you to the root cause faster than adding console.log everywhere. Train yourself to use the debugger — it is a superpower.
What to learn next
You now know how to run JavaScript, set up your tools, and debug effectively. Time to learn the language itself:
- Variables (let, const, var) — how JavaScript stores data and how scope works.
- Data types — the building blocks: strings, numbers, booleans, objects, and more.