User Agents

Web browsers and everyday web tech, explained

View Page Source Safari Mac: How-To & Tips

· 7 min read · Browsers

In this article
  1. Why View Page Source in Safari?
  2. How to Enable the Develop Menu
  3. Three Ways to View Page Source
  4. What You’ll See in the Source
  5. Common Problems and Solutions
  6. Safari vs. Other Browsers
  7. Privacy and Security Considerations
  8. Alternatives to Viewing Source
  9. Frequently Asked Questions

To view page source in Safari on a Mac, press Option+Command+U (⌥⌘U) or right-click the page and select “Show Page Source” from the context menu. This opens the Web Inspector with the raw HTML, CSS, and JavaScript of the current page, which is useful for debugging, learning, or checking how a site is built.

Why View Page Source in Safari?

Viewing the source code of a webpage lets you see the exact HTML that the browser receives. Unlike the rendered page you see, the source shows the underlying structure: headings, links, images, scripts, and metadata. This is valuable for web developers, designers, SEO specialists, and curious users who want to understand how a site works, find a specific element, or troubleshoot why something looks wrong. Safari’s Web Inspector also gives you access to the DOM (Document Object Model), CSS styles, network requests, and console logs, making it a full-featured development tool, not just a source viewer.

How to Enable the Develop Menu

The quickest way to view source is the keyboard shortcut, but to access the full set of developer tools, you should enable the Develop menu. Here’s how:

  1. Open Safari and go to Safari > Settings (or Preferences in older macOS versions).
  2. Click the Advanced tab.
  3. Check the box next to “Show features for web developers” at the bottom of the window.

Once enabled, you’ll see a new Develop menu in the menu bar. This menu includes options like “Show Page Source,” “Show JavaScript Console,” and “Show Responsive Design Mode,” which are essential for testing and debugging.

Three Ways to View Page Source

There are several methods to open the source, and the best one depends on your situation:

  • Keyboard shortcut: Press Option+Command+U on the page you want to inspect. This is the fastest method and works in all versions of Safari that support the Develop menu.
  • Right-click menu: Right-click (or Control-click) anywhere on the page and select “Show Page Source” from the context menu. If you don’t see this option, make sure the Develop menu is enabled as described above.
  • Develop menu: Click Develop > Show Page Source in the menu bar. This is useful if you’re already using other developer tools.

All three methods open the Web Inspector with the source view active. You can switch between the source, console, and other panels using the tabs at the top of the inspector window.

What You’ll See in the Source

The source view in Safari’s Web Inspector is more than just raw HTML. It provides a color-coded, line-numbered view of the document, with several helpful features:

  • Syntax highlighting: Tags, attributes, and text are color-coded for readability.
  • Line numbers: Useful for referencing specific lines when debugging or sharing code.
  • Collapsible sections: You can expand and collapse elements to focus on specific parts of the code.
  • Search: Use the search bar at the top of the inspector to find specific strings, tags, or attributes.
  • Link to resources: Clicking on a linked CSS or JavaScript file will open it in a separate tab within the inspector.

Remember that the source you see is the HTML as delivered by the server. If the page uses JavaScript to modify content after loading, the source may not reflect the final state. To see the live, updated structure, use the Elements tab (or “Inspect Element” from the right-click menu), which shows the current DOM.

Common Problems and Solutions

Sometimes the source view doesn’t work as expected. Here are common issues and fixes:

  • “Show Page Source” is grayed out: This happens when the Develop menu is not enabled. Go to Settings > Advanced and check the “Show features for web developers” box.
  • The shortcut does nothing: Make sure you’re pressing the correct keys. On some keyboards, the Option key is labeled “Alt.” Also, try using the right-click method to confirm the feature works.
  • Source is empty or shows only a few lines: This can occur on pages that are heavily generated by JavaScript, such as single-page applications. The server may send a minimal HTML shell, and the rest is built by scripts. Use the Elements tab to see the live DOM instead.
  • Can’t copy the source: You can select text in the source view and copy it normally. If you need the entire source, press Command+A to select all, then Command+C to copy.

If you need to view source on a page that blocks right-clicking, the keyboard shortcut still works. However, some sites use JavaScript to prevent the shortcut; in that case, you can disable JavaScript temporarily via the Develop menu (Develop > Disable JavaScript), reload the page, and then view the source.

Safari vs. Other Browsers

Each major browser has its own way to view source, but the concept is the same. Here’s a quick comparison:

  • Safari: Uses the Web Inspector, which is integrated into the browser. The shortcut is Option+Command+U.
  • Chrome: Right-click > “View Page Source” or press Option+Command+U (same shortcut). It opens a dedicated source tab, not the full DevTools.
  • Firefox: Right-click > “View Page Source” or press Command+U. It also has a separate source viewer.
  • Edge: Similar to Chrome, right-click > “View Page Source” or press Command+U.

While the shortcut is consistent across browsers, Safari’s Web Inspector is more tightly integrated with the browser’s rendering engine, which can be helpful for testing Safari-specific issues. For general web development, many developers use Chrome’s DevTools because of its advanced features, but Safari’s tools are perfectly capable for most tasks.

Privacy and Security Considerations

Viewing page source is completely safe and doesn’t expose any private information. The source code is public – every browser receives it to render the page. However, be aware that the source may contain comments, hidden form fields, or API endpoints that developers didn’t intend to be seen. This is not a security vulnerability per se, but it can reveal how a site works, which is why some sites obfuscate their JavaScript or minify their code.

When viewing source, you might see external resources like tracking scripts or third-party widgets. This is normal. If you’re concerned about privacy, you can use Safari’s built-in privacy report (Safari > Privacy Report) to see what trackers are blocked.

Alternatives to Viewing Source

If you want to see the code behind a page but don’t want to use the Web Inspector, there are a few alternatives:

  • Save the page: Press Command+S to save the entire page as an HTML file. You can then open it in any text editor (like TextEdit or VS Code) to view the source.
  • Use a third-party extension: Some Safari extensions add a “View Source” button to the toolbar. These are not necessary, but they can be convenient if you frequently view source.
  • Use the “Inspect Element” feature: Right-click on a specific element and select “Inspect Element” to jump directly to that element in the DOM. This is often more useful than viewing the whole source.

For debugging, the Web Inspector is the best tool. For simply reading the code, saving the page or using a text editor might be more comfortable.

Frequently Asked Questions

Why can’t I right-click to view source on some websites?

Some websites use JavaScript to disable the right-click context menu to prevent casual copying or to enforce their own menu. However, the keyboard shortcut (Option+Command+U) and the Develop menu method still work because they are part of the browser, not the webpage. If the shortcut is also blocked, try disabling JavaScript temporarily via the Develop menu, reload the page, and then view the source.

Does viewing page source work on any Mac with Safari?

Yes, the feature is available in all modern versions of Safari on macOS. The keyboard shortcut and right-click option work once the Develop menu is enabled. On older macOS versions, the setting is in Preferences > Advanced, but the process is the same.

Can I view the source of a page that requires login?

Yes, you can view the source of any page you are currently viewing, including pages behind a login. The source is the HTML that your browser has already received. However, you won’t see any data that is loaded dynamically after the initial page load unless you inspect the DOM or network requests.

What is the difference between “Show Page Source” and “Inspect Element”?

“Show Page Source” displays the raw HTML as it was sent by the server. “Inspect Element” opens the Web Inspector’s Elements tab and highlights the selected element in the live DOM, which includes any changes made by JavaScript. For dynamic pages, the Elements tab is more accurate for seeing what’s currently on the screen.

Is there a way to view source in Safari on iPhone or iPad?

No, Safari on iOS does not have a built-in “View Source” feature. You can use third-party apps or bookmarklets, but Apple doesn’t provide a native way. For development, it’s recommended to use a Mac with Safari’s Web Inspector connected to the iOS device via the Develop menu.

Can I edit the source and see the changes live?

Yes, in the Web Inspector, you can double-click on any element in the Elements tab and edit its HTML or CSS. Changes are applied immediately in the browser, but they are not saved – they only affect your current session. This is useful for testing tweaks without modifying the actual files.