Safari URL Scheme for macOS and iOS

null

This will open my website in Safari on macOS, no matter your default browser:

x-safari-https://christiantietze.de

Try it!

Depending on your platform and browser, this may not be clickable or not do anything (I have no clue what Android browsers would do with this).

I was looking for this because I was dissatisfied with how I tabbed into Safari in a screencast recently.

With a link like this, I can open Safari from my notes, e.g. from within The Archive during demonstrations.

Update 2024-06-20: For mobile Safari on iOS, it’s used to be com-apple-mobilesafari-tab:https://christiantietze.de. This was discovered using Shortcuts to reveal the browser’s scheme. This no longer works, though. But asking on Mastodon, people found that the formerly macOS-exclusive x-safari-https: scheme works on iOS now, too! Thanks to @yee@g0v.social, @shadowfacts@social.shadowfacts.net, and Tim Johnsen @timonus@mastodon.social who tested this on iOS 15/17/18! On iOS 16, this apparently does not work.

All of Safari’s URL Schemes

There haven’t been a lot of useful references on the web, so I looked myself; how do you figure out which URL Scheme an app supports?

  1. Locate the .app bundle; for Safari, since it’s in a protected system folder, it’s easiest to search for “Safari” in Spotlight (+ (that’s the space key)) and then reveal the match in Finder (+R).
  2. Right-click the app, “Show Package Contents”;
  3. inside the Contents/ folder,
  4. view the Info.plist file in a text editor of your choice.
  5. Search for CFBundleURLTypes. This key is associated with an array of values (you’ll notice these as they are indented a bit to the right).

This is the relevant section from Safari’s Info.plist as of today in Ventura:

<key>CFBundleURLTypes</key>
<array>
  <dict>
	<key>CFBundleURLName</key>
	<string>Web site URL</string>
	<key>CFBundleURLSchemes</key>
	<array>
	  <string>http</string>
	  <string>https</string>
	</array>
	<key>LSHandlerRank</key>
	<string>Default</string>
	<key>LSIsAppleDefaultForScheme</key>
	<true/>
  </dict>
  <dict>
	<key>CFBundleURLName</key>
	<string>Local file URL</string>
	<key>CFBundleURLSchemes</key>
	<array>
	  <string>file</string>
	</array>
	<key>LSHandlerRank</key>
	<string>Default</string>
  </dict>
  <dict>
	<key>CFBundleURLName</key>
	<string>Safari Start Page</string>
	<key>CFBundleURLSchemes</key>
	<array>
	  <string>x-safari-https</string>
	</array>
  </dict>
  <dict>
	<key>CFBundleURLSchemes</key>
	<array>
	  <string>prefs</string>
	</array>
	<key>LSHandlerRank</key>
	<string>None</string>
  </dict>
  <dict>
	<key>CFBundleURLSchemes</key>
	<array>
	  <string>x-webkit-app-launch</string>
	</array>
	<key>LSHandlerRank</key>
	<string>None</string>
  </dict>
</array>

Apart from http and https, Safari also registers for the file protocol.

Then you see x-safari-https, prefs, and x-webkit-app-launch.