As a web design project manager, I sometimes need to check a link from my iPhone. Where does it actually point? When I first wrote this post, I used a little app called View Source. For a quick look at the HTML in the Safari tab you already have open, you can now make your own Share button action with Apple’s Shortcuts.
Add a View Page HTML shortcut to Safari
- Open Shortcuts, tap + and name the shortcut View Page HTML. In the shortcut’s Details, turn on Show in Share Sheet. In the input line at the top, select Safari Web Pages as the accepted type.
- Add the Run JavaScript on Web Page action. Set its webpage input to Shortcut Input. Replace the sample script with the single line below.
- Add Show Result immediately after the script and use its output as the result. Save the shortcut.
completion(document.documentElement.outerHTML);In Settings, find Shortcuts → Advanced and enable Allow Running Scripts if it’s off. The line above reads the current page’s HTML and returns it to Shortcuts. Apple walks through the permission and setup in its guide to running JavaScript on a webpage.
Use it on a page
Open an ordinary webpage in Safari, tap Share, then View Page HTML. Approve the shortcut if prompted. You should see text containing tags such as <head> and <body>. If the shortcut is missing, check that you shared the open Safari page itself. Sharing a copied address passes a different kind of input.
Is that the original page source?
It’s the HTML Safari has in memory when you tap Share. Say a menu inserts a link after you open it. The shortcut can show that link even when it was missing from the HTML the server first sent. It also shows references to external stylesheets and scripts rather than the contents of those files.
If you need the original response for troubleshooting, connect the iPhone to a Mac and use Safari Web Inspector. Open its Network tab, reload the page on the phone and inspect the main document’s response. That lets you compare what arrived with what Safari is displaying.
Prefer the original View Source app?
Roman Tomjak’s View Source for iPhone is still an option. It has search and syntax highlighting, both handy if you’re looking for one URL in a long WordPress page. Once installed, open Safari’s Share menu and choose View Source. That was the part I liked about the original method: once it’s set up, it’s right there when you need it.
For another way to adjust Safari on an iPhone, see how to move the search bar.

