Skip to content

Instantly share code, notes, and snippets.

Last active February 8, 2023 19:15
What would you like to do?
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)

By @kepano

🎉 Support my work at


You can find a demo of this bookmarklet on YouTube


Create a new bookmark in your browser, then copy/paste the minified code below into the URL field.

You can customize the output using the optional variables at the top, and the template at the bottom. The default template is designed for use with the Dataview plugin. If you make changes I recommend using Bookmarklet Maker to minify and URI encode the bookmarklet.


By default, clicking the bookmarklet creates a new Obsidian file from the main body of the article (similar to Readability view). Alternatively you can choose to create a file from a selection, by either selecting all (CMD+A), or just a portion of the page.

Any images in the content will be embedded as external references. If you want to download images locally you can use the Local Images plugin which allows you to download images for a note.


This bookmarklet may not work on all websites. If you run into issues, you can also try the MarkDownload browser extension which provides similar functionality. You can troubleshoot issues by opening the Developer Console in your browser and checking if any errors appear when you click the bookmarklet. The most common error is that a website or the browser itself is blocking third party code execution. Unfortunately there is no good solve for that yet.

javascript: Promise.all([import(''), import(''), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
const folder = "";
/* Optional tags */
const tags = "#clippings";
function getSelectionHtml() {
var html = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
html = container.innerHTML;
} else if (typeof document.selection != "undefined") {
if (document.selection.type == "Text") {
html = document.selection.createRange().htmlText;
return html;
const selection = getSelectionHtml();
const {
} = new Readability(document.cloneNode(true)).parse();
function getFileName(fileName) {
var userAgent = window.navigator.userAgent,
platform = window.navigator.platform,
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
if (windowsPlatforms.indexOf(platform) !== -1) {
fileName = fileName.replace(':', '').replace(/[/\\?%*|"<>]/g, '-');
} else {
fileName = fileName.replace(':', '').replace(/\//g, '-').replace(/\\/g, '-');
return fileName;
const fileName = getFileName(title);
if (selection) {
var markdownify = selection;
} else {
var markdownify = content;
if (vault) {
var vaultName = '&vault=' + encodeURIComponent(`${vault}`);
} else {
var vaultName = '';
const markdownBody = new Turndown({
headingStyle: 'atx',
hr: '---',
bulletListMarker: '-',
codeBlockStyle: 'fenced',
emDelimiter: '*',
var date = new Date();
function convertDate(date) {
var yyyy = date.getFullYear().toString();
var mm = (date.getMonth()+1).toString();
var dd = date.getDate().toString();
var mmChars = mm.split('');
var ddChars = dd.split('');
return yyyy + '-' + (mmChars[1]?mm:"0"+mmChars[0]) + '-' + (ddChars[1]?dd:"0"+ddChars[0]);
const today = convertDate(date);
const fileContent =
"author:: " + byline + "\n"
+ "source:: [" + title + "](" + document.URL + ")\n"
+ "clipped:: [[" + today + "]]\n"
+ "published:: \n\n"
+ tags + "\n\n"
+ markdownBody ;
document.location.href = "obsidian://new?"
+ "file=" + encodeURIComponent(folder + fileName)
+ "&content=" + encodeURIComponent(fileContent)
+ vaultName ;
Copy link

aancw commented Aug 20, 2022

I'm experiencing the issue that selection mode is not working on Safari. But work very well on chrome and firefox.

Ref: mdn/browser-compat-data#14270 (comment)

Edit: I think the problem is when clicking bookmarklet the selection is cleared because safari popup notification for obsidian

Screen Shot 2022-08-20 at 16 57 01

Copy link

leotulipan commented Oct 17, 2022

On my Windows 10 with Google Chrome I had to add this to the registry and then it works.

Got the tip via this thread and used the Obsidian Clipper Maker


Windows Registry Editor Version 5.00



Copy link

stormer commented Oct 24, 2022

This is working great in Chrome but I'm wondering whether it's possible to get it working in Safari - I've tried the same procedure in Safari but to no avail.

Copy link

This is working great in Chrome but I'm wondering whether it's possible to get it working in Safari - I've tried the same procedure in Safari but to no avail.

I use it in Safari every day...

Copy link

stormer commented Oct 24, 2022

@wealthychef1, maybe it's a Mac thing (I'm on a Mac). Still working great in Chrome but in Safari the load bar starts but then gets stuck.

Copy link

I'm getting an error on some websites because the titles can't contain certain characters. Is there a regex expression you can insert somewhere to prevent that error?

Copy link

@wealthychef1, maybe it's a Mac thing (I'm on a Mac). Still working great in Chrome but in Safari the load bar starts but then gets stuck.

I'm using Safari Version 16.0 (17614., 17614) on MacOS Monterey 12.6

Copy link

How can I fix the errors found in my developers console? The web clippings do not save. Thanks

Copy link

Write commented Oct 30, 2022

How can I fix the errors found in my developers console? The web clippings do not save. Thanks
Can you post your console logs ?

I'm afraid it's a CSP issue, then it's not fixable.

Copy link

vitr commented Nov 6, 2022

Sorry for the irrelevant issue, but why does the bookmarklet not work with this page or any other gist or GitHub page?

Copy link

Sorry for the irrelevant issue, but why does the bookmarklet not work with this page or any other gist or GitHub page?

@vitr That's the same answer as in

GitHub's CSPs cannot be "bypassed" w/o using a server side. I had to wrote a personal webservice in order to make this work w/ GitHub and some other sites ( JFYI)

P.S.: Heroku is going to shut down free tier hosting, so don't think to use my experimental publix webservice: it will be shut down and maybe moved away sooner than later

Copy link

vitr commented Nov 8, 2022

thanks, I guess, browser extensions (e.g. work with any page, as they have full access to the content

Copy link

thanks, I guess, browser extensions (e.g. work with any page, as they have full access to the content

You're right @vitr (AFAIK)! If that fits your flow, than it seems a sturdy option to me

Copy link

Hi, thanks for this great plugin! I have a small issue. Somehow images are not exported to Obsidian from voxeu (an economics website). I tried different articles from there, but they always export without pics. Here is an example site:

Any way to remedy this?

Copy link

I just can't get this bookmarklet to work with any of the sites I read.
When I click it absolutely nothing happens. No notes appear in obsidian. I use Brave browser.
"MarkDownload" and "Obsidian Web" extensions for chrome work.

Copy link

thanks for creating this - one FYI for chrome on Android. I was running into a max length issue for the generated bookmarklet URI. Seems like URI couldn't be > 5000 characters (when pasting in the javascript code, the text box (?) was limiting the # of characters allowed, truncating to about 5000 chars). So nothing worked - no clipping nor errors.

I didn't spend too much time but my workaround was to delete/modify a couple things from javascript (content template, comments) and re generate with the bookmarklet maker linked above. Now generated is ~4800 chars and whole pages seem to work but not selected subset. Good enough for me at the moment. (Android 12, samsung tablet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment