> ## Content Index
> Fetch the complete content index at: https://airabbit.blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Convert HTML to Markdown Bookmarklet
- URL: https://airabbit.blog/convert-html-to-markdown-bookmarklet/
- Published: 2024-12-11T14:25:03.000Z
- Updated: 2025-03-21T15:40:46.000Z
- Description: Transform your web content effortlessly with this handy JavaScript snippet that utilizes the Turndown library! Simply highlight your text or select an article, and convert it to Markdown format. Enjoy a user-friendly popup for easy copying and closing—perfect for enhancing your content workflow!
- Author: AiRabbit
- Tags: Development, Tutorials

````
javascript:(function(){if(typeof TurndownService==='undefined'){var s=document.createElement('script');s.src='https://cdnjs.cloudflare.com/ajax/libs/turndown/7.1.2/turndown.min.js';s.onload=i;document.body.appendChild(s)}else{i()}function i(){var s=window.getSelection();var h='';if(s.rangeCount>0){var c=document.createElement('div');var r=s.getRangeAt(0);c.appendChild(r.cloneContents());h=c.innerHTML}else{var a=document.querySelector('article');if(a){h=a.innerHTML}else{alert('No selection found and no article element detected');return}}if(!h){alert('No content found to convert');return}var t=new TurndownService({headingStyle:'atx',codeBlockStyle:'fenced',emDelimiter:'*',strongDelimiter:'**'});var m=t.turndown(h);var d=document.createElement('div');d.style.cssText='position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:white;padding:20px;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.5);z-index:10000;max-width:80%;max-height:80vh;overflow:auto;';var a=document.createElement('textarea');a.value=m;a.style.cssText='width:100%;min-height:200px;margin-bottom:10px;padding:8px;';var b=document.createElement('button');b.textContent='Close';b.style.cssText='padding:8px 16px;background:#f0f0f0;border:none;border-radius:4px;cursor:pointer;';b.onclick=function(){document.body.removeChild(d)};var%20y=document.createElement('button');y.textContent='Copy';y.style.cssText='padding:8px%2016px;background:#007bff;color:white;border:none;border-radius:4px;margin-right:10px;cursor:pointer;';y.onclick=function(){a.select();document.execCommand('copy');y.textContent='Copied!';setTimeout(()=%3E{y.textContent='Copy'},2000)};d.appendChild(a);d.appendChild(y);d.appendChild(b);document.body.appendChild(d)}})();
```