TL;DR: Browser DevTools (F12 or Cmd+Option+I on Mac) give you a live view of your web app's JavaScript errors, network requests, HTML structure, and CSS styles. The Console shows errors and lets you run JavaScript. The Network tab shows every API call and its response. The Elements tab shows the rendered HTML and lets you modify CSS live. The Sources tab lets you set breakpoints and step through JavaScript. These four panels solve 90% of frontend debugging problems.
Opening DevTools
- Windows/Linux: F12 or Ctrl+Shift+I
- Mac: Cmd+Option+I
- Right-click anything on the page → Inspect
DevTools opens docked to the bottom or side. You can undock it into its own window (click the three-dot menu → Undock into separate window) which is helpful on smaller screens.
The Console Panel
The Console is the first place to look when something is broken. It shows JavaScript errors, warning messages, and anything your code logs with console.log().
Reading error messages
Every console error includes:
- The error message itself
- The file name and line number (click it to jump to the Sources panel)
- A stack trace showing the call chain that led to the error
Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at UserProfile (UserProfile.jsx:24:18)
at renderWithHooks (react-dom.development.js:14985:18)
This tells you: UserProfile.jsx line 24 tried to read .name from something that is undefined. The fix is in your component — something is undefined when the component renders, likely a prop or async data that has not loaded yet.
Running JavaScript in the Console
The Console is a live JavaScript REPL. You can run any code against the current page:
// Inspect a variable value
document.title
// Test a function
JSON.parse('{"name":"Chuck"}')
// Check localStorage
localStorage.getItem('authToken')
// Inspect the current URL
window.location.href
This is invaluable for debugging — you can test fixes directly in the console before writing them in your code.
Filtering console output
Click the filter icons at the top of the Console to show only Errors, Warnings, or Info messages. When AI generates lots of console.log debugging statements, filtering to Errors only shows what is actually broken.
The Network Panel
The Network panel records every HTTP request your page makes — HTML, CSS, JavaScript files, API calls, images. For debugging AI-generated apps that fetch data, this is your most important panel.
Finding API requests
- Open DevTools → Network tab
- Reload the page (or trigger the action that makes the request)
- Click "Fetch/XHR" to filter to API calls only
- Click any request to see its details
For each request you can inspect:
- Headers tab: Request method, URL, request headers (including Authorization tokens), response headers (including CORS headers)
- Payload tab: The request body — what your app sent to the server
- Response tab: What the server sent back — the actual JSON data
- Preview tab: The response formatted for easy reading
- Timing tab: How long each phase took (DNS lookup, connection, waiting, download)
Debugging failed requests
Failed requests show in red. Common failure patterns:
- Status 404: Wrong URL — check the endpoint path
- Status 401/403: Auth token missing or invalid — check request headers
- Status 429: Rate limited — too many requests
- Status 500: Server error — check your backend logs
- CORS error: No response — check the Console for the specific CORS error message
- (failed): Network error — server unreachable, check if your dev server is running
The Network waterfall
The waterfall chart shows when each request starts and how long it takes. Long bars in the "Waiting (TTFB)" column mean your server is slow to respond. Long bars in the "Download" column mean large payloads. Stacked sequential requests suggest you should use Promise.all() to parallelize.
The Elements Panel
The Elements panel shows the live HTML of your page and its computed CSS styles. It is essential for debugging layout and styling issues.
Inspecting an element
Right-click any element on the page → Inspect. The Elements panel jumps to that element in the HTML tree. The Styles panel on the right shows all CSS rules applied to it, where they come from (which stylesheet), and whether any rules are being overridden (shown with strikethrough).
Live CSS editing
Click any CSS value in the Styles panel to edit it. Press Tab to move to the next property. Changes apply instantly to the page. This is the fastest way to experiment with CSS fixes — find what works in DevTools, then copy the values to your actual stylesheet.
Box model visualization
The Computed tab shows the element's box model — its content size, padding, border, and margin visually. When layout is broken (elements overlapping, wrong sizes), the box model usually reveals why immediately.
The Sources Panel
The Sources panel lets you read the JavaScript your browser is running and set breakpoints to pause execution and inspect variables.
Setting a breakpoint
- Open Sources → find your file in the file tree
- Click a line number to set a breakpoint (blue marker appears)
- Trigger the code that runs that line
- Execution pauses at the breakpoint
- Hover variables to see their current values
- Use the resume/step buttons to continue execution
This is far more powerful than console.log debugging — you can inspect any variable at any point in execution, not just values you thought to log ahead of time.
Essential Debugging Workflows
Debugging "data is undefined"
- Open Console — look for the specific error and line number
- Open Network → find the API request — did it succeed? What did it return?
- Add a
console.logright before the undefined access to see what the value actually is - Usually: data has not loaded yet (missing loading state), wrong property path, or API returned an error
Debugging CSS layout issues
- Right-click the broken element → Inspect
- Check the Styles panel — is the expected CSS rule present? Is it overridden?
- Check the Computed tab → Box Model — is the element the expected size?
- Try CSS changes live in the Styles panel until it looks right
- Copy the fix to your stylesheet
Debugging a broken API call
- Open Network → filter to Fetch/XHR
- Trigger the action that makes the call
- Click the request → check Status, Headers, and Response
- For CORS errors: check the Console for the specific blocked header
- For 401: check the Authorization header is present and correct
- For unexpected data: check the Response tab to see what the server actually returned
The DevTools Habit
Open DevTools before you start debugging — not after you are stuck. Develop the reflex of having DevTools open whenever your app is running in the browser. The Console and Network tabs catch problems the moment they happen, not after you have been guessing for 20 minutes.
What to Learn Next
- What Is JavaScript? — Understanding JS helps you read the code in the Sources panel.
- What Is CORS? — CORS errors are the most common Network tab failure.
- What Is JSON? — API responses in the Network tab are JSON.
- What Is a Promise? — Most Network tab errors involve async/Promise issues.
Next Step
Open DevTools on your current project right now. Check the Console for any errors you have been ignoring. Then click through the Network tab on a page load and read one API response. Thirty minutes of deliberate DevTools exploration is worth more than hours of guessing why things are broken.
FAQ
Press F12 (Windows/Linux) or Cmd+Option+I (Mac). You can also right-click anywhere on the page and choose Inspect. DevTools is built into Chrome, Firefox, Safari, and Edge — no installation needed.
The Console shows JavaScript errors, warnings, and any console.log() output from your code. It also lets you run JavaScript directly against the current page to test values and functions. It is the first place to look when something is broken.
The Network tab records every HTTP request the page makes — API calls, images, scripts, stylesheets. Click any request to see its URL, method, request headers, request body, response status, and the actual response data. Essential for debugging API failures.
Open the Console and read the error message carefully — it includes the file name and line number. Click the file/line link to jump to that code in the Sources panel. Set a breakpoint on the line before the error and re-run to inspect variable values at that point in execution.
Yes. Right-click any element, choose Inspect, and edit CSS values directly in the Styles panel. Changes apply instantly. This is the fastest way to experiment with CSS fixes. Copy the working values to your stylesheet when done — DevTools changes do not persist after reload.