<h1>Google Drive Link Converter</h1>
<p>Enter a Google Drive sharing link here:</p>
<input type="text" id="shareLink" placeholder="Paste sharing link">
<button onclick="convertLink()">Convert Link</button>
<br>
<br>
<div id="downloadLink"></div>
JavaScript
function convertLink() {
const shareLink = document.getElementById("shareLink").value;
//https://drive.google.com/file/d/1BjSvPzNZOyJ0HfG4y7J3IcUti_LCUKHe/view?usp=sharing
// Extract the file ID from the sharing link
const url_obj = new URL(shareLink);
const fileId = url_obj.pathname.split('/')[3];
if (!fileId) {
alert("Invalid Google Drive sharing link. Please check the URL.");
return;
}
// Construct the downloadable link
const downloadLink = `https://drive.google.com/uc?export=download&id=${fileId}`;
// Display the downloadable link
document.getElementById("downloadLink").innerHTML = `Download Link: <a href="${downloadLink}" target="_blank">${downloadLink}</a>`;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.