I previously blogged how to create one-click direct download links, but that post was exclusive to the classic experience in SharePoint (or any opportunity in which we could use classic html/css).
Normally, to download a document in modern SharePoint Online libraries, we would have to use a file’s menu (right-click or ellipsis) then choose Download.

I was recently challenged to help figure out how to create a single click experience to immediately download a document in modern SharePoint Online libraries and after much trial and error was able to do so using a little bit of JSON in a calculated column.
Here’s how to create a Download link column in modern SharePoint libraries:
1. Create a calculated column (Library Settings > Create Column) named Download and set its formula to =””

2. Copy and paste the following JSON code into the JSON formatting field of the calculated column settings.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "Download",
"attributes": {
"target": "_blank",
"href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
}
}
3. Set the new column to show in the default view so it’s visible in the library and click OK.

4. Return to your library, and test it out!

And if you want anonymous users to be able to use these convenient download links, be sure to share a FOLDER link with the anonymous user(s) so they will see the file in the library alongside the one-click download link.
Optional formatting of the Download link
And while I’m not a JSON expert, I did dabble a bit in stylizing the Download link so it would look a little bit better. You can add a little bit of style to the JSON to achieve a more button-like experience (or for the advanced among you, change the element to an actual button or download icon).
Here’s how you can get started stylizing the text link (see result at bottom):
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "Download",
"style": {
"background-color": "gray",
"text-decoration": "none",
"color": "white",
"font-size": "14px",
"padding-left": "5px"
},
"attributes": {
"target": "_blank",
"href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
}
}

Optional usage of the file’s name instead of “Download”
One small change to the JSON will reference the file’s name for the link instead of using “Download” for all links. Then you could hide Name and just use your Download column.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "[$FileLeafRef]",
"attributes": {
"target": "_blank",
"href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
}
}

Great idea but not working, File NOt Found?
Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: 51f34fa0-903e-4000-78f5-e06b91b67726
Date and Time: 11/07/2022 04:32:28
I have the same issue. Any insights here? Some of the files work and some say File not Found like this error.
Thanks for the very useful post. is there anyway we could tweak the JSon if there is folder. Because when i am clicking on folder, receiving error, nothing to download. how to use condition that if there is folder nothing to do rather throwing error.
Love the idea, of the button, but is their a way to restrict folder downloads, so it is only possible to download files?
OMG, what I’ve been looking for. Is there a json option for the online app (without powerautomate)
This is amazing Nate! I tried the solution and had no issue except when I tried to download an entire folder from the document library. Do you know if there is a work around for downloading an entire folder from a library using the same download column methodology, or in the same way that you have outlined for an individual document in a folder?
This is amazing! I love it!
Thanks, Nate – I can see how useful this might be in certain instances for our university!
Nice! Love this super useful tip!