YouTube Music Lyrics Bookmarklet

This compact bookmarklet helps you quickly extract the currently playing track's metadata (title, artist, duration) and lyrics from YouTube Music, formatting the output as clean markdown with HTML line wrappers for perfect line breaks.

The lyrics lines are wrapped individually in <div> tags, with blank lines replaced by <p></p>, preserving the song’s structure exactly as it appears.


Features


How to use

  1. Create a new bookmark in your browser.
  2. Paste the entire bookmarklet code (see below) into the bookmark’s URL/location field.
  3. Open a track page on YouTube Music where lyrics are visible.
  4. Click the bookmarklet.
  5. The formatted markdown text including metadata and lyrics is now copied to your clipboard.
  6. Paste it anywhere you want (notes, blog, etc.) — the line breaks will be preserved correctly!

Bookmarklet code

javascript:(async()=>{try{const w=async(s,t=3e3)=>{const e=Date.now();while(Date.now()-e<t){const r=document.querySelector(s);if(r)return r;await new Promise(n=>setTimeout(n,100))}return null},c=async(i)=>{const t=document.querySelectorAll('tp-yt-paper-tab');if(t.length<=i)return!1;t[i].click();await new Promise(n=>setTimeout(n,700));return!0};if(!(await c(0))){alert('Could not find or click metadata tab.');return}const s=await w('ytmusic-player-queue-item[selected]');if(!s){alert('Could not find selected queue item.');return}const t=s.querySelector('.song-title')?.textContent.trim()||%27Unknown%20Title%27,n=s.querySelector(%27.byline%27)?.textContent.trim()||%27Unknown%20Artist%27,r=s.querySelector(%27.duration%27)?.textContent.trim()||%27Unknown%20Duration%27;if(!(await%20c(1))){alert(%27Could%20not%20find%20or%20click%20lyrics%20tab.%27);return}const%20lAll=document.querySelectorAll(%27ytmusic-description-shelf-renderer%27);if(!lAll.length){alert(%27Could%20not%20find%20any%20lyrics%20containers.%27);return}const%20l=lAll[lAll.length-1];const%20lines=[];for(const%20e%20of%20l.children){if(e.offsetParent!==null){const%20a=e.textContent.split(/\r?\n/);for(const%20i%20of%20a){const%20tr=i.trim();lines.push(tr===%27%27?%27%3Cp%3E%3C/p%3E%27:`%3Cdiv%3E${tr}%3C/div%3E`)}}}if(!lines.length){alert(%27Lyrics%20content%20is%20empty.%27);return}const%20md=`#%20[${t}](${location.href})\n\n**Artist:**%20${n}\n\n**Duration:**%20${r}\n\n---\n\n${lines.join('\n')}%60;await%20navigator.clipboard.writeText(md);alert('Lyrics%20with%20div/p%20wrappers%20and%20metadata%20copied%20to%20clipboard!')}catch(e){alert('Error:%20'+e.message)}})();

Behind the scenes

This bookmarklet was crafted with the help of OpenAI ChatGPT and Google Gemini, combining AI’s ability to parse complex DOM structures and your coding vision to build a reliable, compact, and user-friendly tool.

Example output:


# [Girl, You'll Be A Woman Soon](https://music.youtube.com/watch?v=K_fZCD93LzQ&list=RDAMVMK_fZCD93LzQ)

**Artist:** Neil Diamond

**Duration:** 3.20

---

<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<div>Girl, you'll be a woman soon</div>
<p></p>
<div>Love you so much can't count all the ways</div>
<div>I'd die for you girl and all they can say is</div>
<div>"He's not your kind"</div>
<div>They never get tired of puttin' me down and</div>
<div>I never know when I come around</div>
<div>What I'm gonna find</div>
<div>Don't let them make up your mind</div>
<div>Don't you know</div>
<p></p>
<div>Girl, you'll be a woman soon</div>
<div>Please come take my hand</div>
<div>Girl, you'll be a woman soon</div>
<div>Soon you'll need a man</div>
<p></p>
<div>I've been misunderstood for all of my life</div>
<div>But what they're sayin', girl, just cuts like a knife</div>
<div>"The boy's no good"</div>
<div>Well, I finally found what I've been lookin' for</div>
<div>But if they get a chance they'll end it for sure</div>
<div>Sure they would</div>
<div>Baby, I've done all I could, it's up to you</div>
<p></p>
<div>Girl, you'll be a woman soon</div>
<div>Please come take my hand</div>
<div>And girl, you'll be a woman soon</div>
<div>Soon you'll need a man</div>
<p></p>
<div>Oh girl, you'll be a woman soon</div>
<div>Please come take my hand</div>
<div>Girl, you'll be a woman soon</div>
<div>Soon you'll need a man</div>
<div>Soon</div>
<div>Kilde: Musixmatch</div>