So I created a .webloc file using a .vncloc file as a template (standard xml/plist format), but instead of opening in a Safari window, it is downloading the html of the website into a file.

My goal is to eventually write a cronjob that keeps the URL of a server with a dynamic IP address up to date in the file (in dropbox) so that I can just double-click it anytime and get the correct server page.

The contents of the file look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

How do I get the .webloc file to actually open and display in Safari, as if I were to have entered the URL myself?

  • Oh yeah, and if I create a webloc file by dragging the URL to the desktop, it's not in this xml/plist format and contains weird characters, which makes me wary about maintaining it via script.
    – hepcat72
    Commented Apr 14, 2015 at 20:27
  • 2
    webloc files written by Safari have a data fork and a resource fork, which is binary (the "weird characters"). See this. Google Chrome creates them here (search that page for WriteURLToNewWebLocFileResourceFork). That said, I tested creating a webloc with your XML above, substituting this site's address. It opened correctly in both Chrome and Safari. Are you sure your webserver is sending the correct headers?
    – tubedogg
    Commented Apr 14, 2015 at 21:01
  • I haven't checked the headers. I thought about that, but I figured that if the site loads fine when you type the URL into the location field, shouldn't it load file in the browser if you open the .webloc file? I'll check the headers. That's got to be it, but why would behavior be different between location field and .webloc file?
    – hepcat72
    Commented Apr 15, 2015 at 21:28
  • No idea. The behavior should be identical. What version of Safari? Did you test in Chrome or Firefox just to see what happens?
    – tubedogg
    Commented Apr 15, 2015 at 21:30
  • Safari 7.1. Didn't think to try to open the .webloc file in another browser. Not sure that should work, but I tried it using FireFox and got an XML parsing error. It didn't like the parameters at the end of the URL string. Perhaps I need to make the special characters in the URL XML-safe. The web page opens fine in FireFox though by typing it in the location field, if that's what you meant.
    – hepcat72
    Commented Apr 15, 2015 at 23:17

2 Answers 2


I found the simplest and most storage space efficient method:

  1. Open TextEdit (or any other plain text editor)
  2. Paste this single line and update the URL in the quotes to your liking.
{ URL = "https://stackexchange.com"; }
  1. Save it as My Bookmark.webloc
  • ✅ Spotlight renders the website at the given URL nicely.
  • ✅ A double-click in Finder opens the URL in Safari nicely.
  • Tested on macOS 11.6.6 Big Sur and Safari 15.5
  • Technically you have created a PLIST file in plain text notation (as Xcode offers it) with the file extension .webloc.
  • 3
    So one could also just do echo '{ URL = "https://stackexchange.com"; }' > SE.webloc?
    – nohillside
    Commented Jun 15, 2022 at 12:28
  • Yes. Works perfectly. The single quotes outside ensure that the inner quotes make it intact into the file. A subsequent open SE.weblocopens it in Safari as it's the default handler for .webloc files. open -a "Google Chrome" SE.webloc also works. open -a "Brave Browser" SE.webloc opens Brave but it fails to open the webloc file.
    – porg
    Commented Jun 16, 2022 at 17:27
  • 1
    As of macOS 10.6.8 with Safari 15.6 this does not work anymore 🙁 . Double-clicking or open your-bookmark.webloc opens the webloc file in Safari, but then instead of loading the URL Safari opens the file in Finder, which gets to the foreground and selects the webloc file in the top window.
    – porg
    Commented Aug 12, 2022 at 13:18
  • 1
    This is a worthwhile answer, but I couldn't get it to work with an app URL like "my-app://" so I had to resort to creating a ".url" file instead of a ".webloc" file using this other answer superuser.com/questions/689441/…
    – Jorge
    Commented Jul 12, 2023 at 7:03
  • ℹ️ QuickLooking a *.webloc file in macOS Finder (with SPACE) renders the web site in the QuickLook window, whereas *.url just shows the generic "Web Location" icon.
    – porg
    Commented Jul 12, 2023 at 11:24

This is not an entirely "manual" solution, it's dependent on a not-free application, Keyboard Maestro.

In this KBM forum thread: https://forum.keyboardmaestro.com/t/problems-creating-a-webloc-file-with-a-given-url/25787/ user ComplexPoint posted a macro that creates a webloc file on the Desktop (configurable) for whatever page is frontmost in Chrome at the moment it's run, using KBM's internal token %ChromeURL%. KBM also has a token, %SafariURL% for the frontmost Safari tab, which can be used instead.

[Unaffiliated Review]At $36US, it's pricey for just this one task, but I'll argue that KBM can easily become indispensable in its ability to add features to other apps. There is a hugely helpful user forum and prompt support from the current developer. I bought it for myself for my birthday two years ago and I'm now using my custom macros many times per hour. [End of review]


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .