SharePoint Online: Format List View using PowerShell

Requirement: Apply formatting to SharePoint Online View using PowerShell.

How to Apply Formatting to a List View in SharePoint Online?

Similar to column formatting, we can apply formatting to SharePoint Online views as well. Say, you want to apply alternate rows highlighting format for a SharePoint Online list view. Here are the steps to apply formatting to a list view:

  1. Login to your SharePoint Online site >> Navigate to the list and pick the target view you would like to format.
  2. In the Views dropdown, select “Format current View”.format list view in sharepoint online
  3. Apply the JSON to format the view. Preview the results and hit the “Save” button once finalized.alternate rows sharepoint online list view

PowerShell to Set List View Formatting

Alright, How about setting the view format using PowerShell? Here is the PowerShell script to apply formatting to a SharePoint list view:

$SiteURL = ""
$ListName = "Projects"
$ViewName = "Active Projects"

$JSONFormat = @"
  "$schema": "",
  "additionalRowClass": "=if(@rowIndex % 2 == 0,'ms-bgColor-themeLighter ms-bgColor-themeLight--hover','')"
    #Connect to site
    Connect-PnPOnline -URL $SiteURL -Interactive
    #Set the View Formatting
    Set-PnPView -List $ListName -Identity $ViewName -Values @{CustomFormatter =$JSONFormat} -ErrorAction Stop
    Write-host "View Format Applied Successfully!" -foregroundcolor Green
Catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

Use this GitHub resource for list view formats from the community:

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *