How to View Website Source Code: 5 Methods & Security Check

On this page
- What You’ll Need Before You Start
- 5 Methods to View Website Source Code (Step by Step)
- How to Audit Third-Party Scripts and Security Risks in Source Code
- How SEO Professionals Use Source Code to Diagnose Issues
- Troubleshooting Common Issues When Viewing Source Code
- Success Criteria: How to Verify You’ve Viewed the Correct Source
- Frequently Asked Questions
- Key Takeaways
Learning how to view website source code is straightforward: right-click any page and select “View Page Source,” or type view-source: before a URL. This guide covers five methods, including command-line and mobile options, plus how to audit that source for third-party scripts and security breaches like the Optimizely legal incident and the 1Password source code breach.
What You’ll Need Before You Start
Tools and permissions required
For the first three methods, any modern desktop or mobile browser will work. For command-line inspection, you need a terminal with curl or wget installed — both come standard on macOS, Linux, and recent Windows builds. You don’t need permission to view the public source code of any website.
Safety note: Viewing source code carries no risk—but downloading or executing code does
Viewing source is read-only. You’re reading a text file the server sent, not executing it. However, if you download scripts and run them locally, or copy-paste into a terminal, you could introduce malware. Stick to inspection.
5 Methods to View Website Source Code (Step by Step)

The table below gives you a side-by-side comparison of what each method does best. Each method below shows you how to see HTML code, whether you’re on a desktop or mobile. The methods that follow deliver depth where the “quick view” ones fall short.
| Method | Best For | Requires | Key Limitation |
|---|---|---|---|
| Right-click View Page Source | Quick desktop check | Desktop browser | Not available on mobile |
| view-source: URL prefix | All devices, no setup | Any browser | Must type manually |
| Developer Tools Inspect Element | Live DOM debugging | Desktop browser | Shows rendered DOM, not raw HTTP response |
| curl / wget | Automation, offline audit | Terminal | No JavaScript rendering |
| Online source viewers | Locked-down devices | Internet access | Third-party may cache or inject |
Method 1: Right-click View Page Source (Desktop)
Step: On any desktop browser (Chrome, Firefox, Edge), right-click an empty area of the page and choose “View Page Source.” Checkpoint: A new tab opens with the raw HTML, starting with <!DOCTYPE html> or <html>. The keyboard shortcut Ctrl+U (Cmd+Option+U on Mac) does the same. For Chrome specifically, this view source code Chrome shortcut is the fastest way to see HTML code in a native window.
Method 2: Using the view-source: URL Prefix (All Devices)
Step: In the browser’s address bar, type view-source: before the full URL — for example, view-source:https://example.com — and press Enter. Checkpoint: You see the raw source even on browsers that hide the “View Source” option, including Safari on iOS and many Android browsers. This is the go‑to technique when you need to view source on mobile, as it works without any installation or bookmarklet.
Method 3: Developer Tools Inspect Element (Desktop)
Step: Press F12 or Ctrl+Shift+I (Cmd+Option+I on Mac) to open Developer Tools. Switch to the Elements (Chrome/Edge) or Inspector (Firefox) tab. Hover over lines to highlight parts of the page. Checkpoint: The live DOM tree appears. Right-click on an element and choose “Edit as HTML” to see the full branch. Keep in mind this is the rendered DOM, not the original HTTP response — a critical inspect element vs view source difference for security and SEO audits.
Method 4: Command-Line curl and wget (Advanced)
Step: Open a terminal. To fetch a page’s source, run:
curl -L https://example.com(the-Lfollows redirects)wget -q -O - https://example.com(outputs to stdout) Checkpoint: Raw HTML prints to the terminal. Pipe it to a file for offline audit:curl -L https://example.com > page.html. A basic curl view source command like this gives you the server’s exact response — essential when you need to automate checks or audit without a browser.
Method 5: Online Source Code Viewers
Step: Navigate to a free online tool such as IP Location’s HTML viewer or Code Beautify’s Source Code Viewer, paste the target URL, and click “View” or “Submit.” Checkpoint: The tool fetches and displays the HTML. A view source online tool like these is ideal when you’re on a locked‑down device or need a quick look without opening a terminal.
How to Audit Third-Party Scripts and Security Risks in Source Code

Identify third-party domains and trackers
Open the source, copy it into a text editor, and search for <script src= or just https?://. Every domain that isn’t the current site’s own domain is a third-party dependency. Document them all. On November 26, 2026, law firm Herbert Smith Freehills Kramer published an analysis of “The Optimizely incident” that highlights a stark reality: a single third-party script can expose you to legal risk if it exfiltrates data or alters page behavior without your explicit knowledge. For site-wide monitoring, a full SEO Audit Services tool can automate the discover-and-track step, but a manual source scan still catches what automated crawlers sometimes miss.
Check for exposed API keys or secrets (1Password lesson)
The November 27, 2026 1Password breach reported by eSecurity Planet occurred because an attacker accessed a GitHub repository that contained source code with embedded credentials. While the breach happened on a code-hosting platform, the lesson transfers directly to websites: never put secrets in public source code. In the HTML you just pulled, search for patterns: api_key, token=, password, secret, authorization, and long base64-like strings. If you find a match, rotate the key immediately. Even a commented-out line can be live in a client’s browser.
Verify code integrity after a breach—the Optimizely angle
After a supply-chain incident, compare today’s source against a known-good baseline. The Optimizely case reminds us that a compromised third-party script can change the number of <script> tags, their order, or the domains they load. Measure the source’s file size and the count of external domains. A sudden jump could indicate an injected skimmer. Microsoft’s “Code Red” outage on November 24, 2026 (Reuters) showed that even internal error messages left in production HTML — stack traces, server paths, database connection strings — give attackers a roadmap. While inspecting source during an incident response, hunt for any such debugging output.
Use the Wayback Machine to view historical source
To see what a page’s source looked like before an incident, visit web.archive.org, enter the URL, pick a snapshot date, and then apply the view-source: prefix to the archived page or use your browser’s View Source. This is how you prove when a malicious script first appeared. For a broader guide on cached versions, see Cached Sites: A Complete Guide to Web Caches.
Practical checklist — perform a website security audit source code scan with these steps on any source you audit:
- List every external
<script src>domain. - Search for the strings
key,token,secret,password. - Compare file size byte count against last known good.
- Check the Wayback Machine for unauthorized changes.
- Look for stack traces or paths containing
var/www,.php,.aspx.
How SEO Professionals Use Source Code to Diagnose Issues
Inspect title tags and meta descriptions
In the raw source, find <title> and <meta name="description". The source tells you exactly what a search engine crawler first sees. If the title is missing, truncated, or JavaScript-injected, you have an indexation problem. A common failure: the source contains <title>Home</title>, but the browser tab shows a dynamic title. That gap means crawlers might never see the full keyword-rich title.
Find canonical URLs and hreflang tags
Search the source for <link rel="canonical" and <link rel="alternate" hreflang. A wrong canonical can silently merge ranking signals into the wrong URL. For international sites, hreflang tags in the source — not in the DOM — guide Google’s regional presentation. Make sure these tags use absolute URLs (starting with https://). For the reasoning behind that, check our piece on Relative vs Absolute URLs: Which Is Better for SEO?.
Check robots meta directives and indexing hints
The raw source might contain <meta name="robots" content="noindex, nofollow">. A left-over noindex from a staging site can wipe traffic overnight. Source-view is the fastest way to spot it before it costs you rankings.
For content teams that need to scale these manual checks across thousands of pages, automated platforms that deeply scan your site — inspecting source-level tags, third-party scripts, and duplicate metadata — can replace hours of manual inspection. Joyrise, for example, bakes that analysis into its daily publishing workflow, flagging SEO gaps as new articles go live.
Troubleshooting Common Issues When Viewing Source Code
Inspect Element vs View Source: Why Source Differs from the DOM
The raw HTML is what the server sent. Inspect Element shows the DOM after JavaScript has rearranged everything. This core inspect element vs view source distinction is critical: if you see a bare <div id="root"></div> in the source but a full tree in Elements, the page is a Single-Page Application (SPA). For SEO and security, the raw source matters most. To capture the fully rendered DOM as a snapshot, right-click the <html> tag in the Elements panel and select “Copy” → “Copy outerHTML.”
Viewing source on iOS Safari and iPad
Safari doesn’t offer a native “View Source” button. Use the view-source: prefix typed directly into the address bar — it works on iOS. Alternatively, add a bookmarklet or install an extension like View Page Source for Firefox on Android if you’re on that browser. An online source viewer also sidesteps the limitation.
Login-required pages and dynamic content
If you view source while already logged into the site, the browser sends your session cookies with the request; you’ll see the gated content’s source. With curl, you must explicitly pass cookies: curl -b cookies.txt https://member.example.com. Without a session, you’ll get the login form’s HTML.
Page returns an error or blank screen
When using curl, a 403 or 503 often means the server blocks non-browser user-agents. Override the user-agent: curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" -L https://example.com. If the source is a blank shell, the content loads client-side; you’ll need a headless browser (Puppeteer, Playwright) to render it first.
Success Criteria: How to Verify You’ve Viewed the Correct Source
Matching raw HTML against expected content
Open the page normally, copy a unique sentence visible to users, then search the source for that exact string. If you find it, you have the actual serving source. If not, that content is JavaScript-rendered and won’t appear in a raw curl or view-source: fetch.
Dealing with compressed or minified code
Many servers send minified HTML — all on a single line. Use a formatter (e.g., Code Beautify’s built-in beautifier) to make it scannable. The content is still there; the byte count alone can tell you if the response is unexpectedly fat or thin.
Frequently Asked Questions
How do I view source code in Chrome mobile?
Prefix the URL with view-source: in the address bar. There is no built-in right-click or menu option on Android Chrome, but the prefix works reliably.
Is view-source: the same as Inspect Element?
No. view-source: shows the raw HTTP response body. Inspect Element shows the live Document Object Model after scripts have run. They often differ, especially on JavaScript-heavy pages.
Can I view the source of a page that requires a login?
Only if you are authenticated. In a standard browser, the view-source: request includes your active session cookies; you’ll see the gated page’s HTML. With command-line tools, you must export cookies or token headers.
Why does the source look different from what I see in the inspector?
Because the inspector reflects post-render DOM, whereas the source is the pre-render payload. JavaScript can add, remove, or rewrite entire page sections after the initial load.
How do I view page source on an iPhone or iPad?
Type view-source: followed by the full URL into Safari’s address bar and hit Go. You’ll see the raw HTML exactly as on desktop.
What is the keyboard shortcut to view source code?
On Windows/Linux: Ctrl+U in most browsers. On Mac: Cmd+Option+U. Alternatively, F12 or Cmd+Option+I opens Developer Tools, where you can inspect the Elements panel.
How can I check for malicious code in website source?
Search for unfamiliar third-party domains, long obfuscated script blocks (random-looking hex strings), and any inline script that loads additional external scripts. Also look for hardcoded tokens or passwords — the 1Password incident demonstrates how secrets left in code can be exploited.
How do I download source code with curl or wget?
curl -o page.html https://example.comwget -O page.html https://example.com
Add -L to follow redirects and a custom user-agent if the server blocks the default string.
Key Takeaways
- Right-click “View Page Source” or the
view-source:prefix gives you instant access to raw HTML on any device. - Audit third-party scripts by domain name — the Optimizely incident shows how unvetted external code creates legal and operational risk.
- Search source for secrets before pushing live — the 1Password breach was enabled by exposed credentials in a repository, and the same can happen in public webpage code.
- Use the raw source (not the Inspect Element DOM) when checking SEO tags like title, canonical, and robots directives, because search engines parse the server response.
- Command-line tools (
curl,wget) and the Wayback Machine let you download, compare, and historically verify source code without a browser.
If scaling these security and SEO checks across your site feels overwhelming, platforms like Joyrise automate source-level site audits and content publishing so you can catch issues before they become incidents.


