SharePoint Online: Format Calculated Column as Hyperlink

Requirement: Format Calculated Column markup as Hyperlink.

How to Format Calculated Column as Link using HTML Markup?
Using calculated column formulas to frame hyperlink and setting the column type to "Number" renders the column markup as HTML. E.g. I've used this formula to link project documents with Projects list.
=CONCATENATE("<a href=''",[ProjectID],">",[Project Name],"</a>")
convert calculated column to hyperlink in sharepoint online

Well, not anymore in SharePoint Online as per the Microsoft announcement Handling HTML markup in SharePoint calculated fields. SharePoint Online renders HTML markup as text instead of HTML!
sharepoint online render calculated column markup as html

So, How to render Calculated column as HTML markups in SharePoint Online? Here is how:
  1. Make sure the list is in New experience, Format the calculated column
    format calculated column as html in sharepoint online
  2. Use this JSON to format the column markup as HTML.
   "$schema": "",
   "elmType": "a",
   "txtContent": "Project Documents",
   "attributes": {
      "target": "_blank",
      "href": "='' + @currentField"
Similarly, you can refer any other fields in the list in JSON as:
"href": "='' + [$Project_x0020_Name]"

This JSON renders the text as HTML markup
sharepoint online render calculated column as html

Here is the Microsoft documentation on column formatting:

Format HTML Markup in Classic Sites
On Classic pages, edit the page in browser, add a script editor web part and place this script in it.
<script src="" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
    var textholder = "";
    $("'<a href=')").each(function() {
        textholder = $(this).text();
How about SharePoint 2016/2019 On-Premises? While the above steps works for SharePoint On-premises, You can configure it at web application level settings using PowerShell.
$WebApp = Get-SPWebApplication http://YOUR-web-app-url


  1. Thanks for this. Worked well

  2. I can't quite get this to work. I left the calculated column as is and even tried using some text rather than column variables and a hardcoded URL in my json and my value displays blank.

    "$schema": "",
    "elmType": "a",
    "txtContent": "TEST",
    "attributes": {
    "target": "_blank",
    "href": "=''"

  3. Thanks very helpful, but please fix the code, single quotation shouldn't be there in the first parameter of concatenate function, which is after this documents/' instead, it should be in third parameter like this "'>"
    =CONCATENATE("",[Project Name],"")

  4. How to add a list field in the "txtContent": "Project Documents" section instead of a text

    1. Say, If you want to display the value of "ProjectName" field instead of static text, use: "txtContent": "[$ProjectName]"

  5. Hi -
    thank you for this code, it's really neat!
    I am an a Classic view and I can't get this to work for the list when the view if Grouped by. Any suggestions?


Please Login and comment to get your questions answered!

Powered by Blogger.