How to Add File Size Column to SharePoint Online Document Library?

Requirement: Add file size column to SharePoint Online.

How to Show File Size in SharePoint Online?

Are you looking to add a column to your SharePoint Online document library that displays the size of each file? Well, You can add the “File Size” column to any list view of the SharePoint Online document library to get the size of each file. Just follow these steps to add the file size column to SharePoint Online:

  1. Navigate to the SharePoint Online Document Library.
  2. Click on the “Views” drop-down in the top-right corner area >> Click on “Edit Current View”.
  3. Search for the “File Size” field under “Columns”, include it in the view, and set the order in which you want it to appear in your view.
  4. Click on “OK” to save the changes to your view.

This adds the “File Size” column to the view and shows the size of each document in the view:

how to add file size column in sharepoint online

Please note, this is the size of the file without version history!

You can also get the size of each file from the properties of the file in Explorer view or from SharePoint Designer!

PnP PowerShell to Add File Size Column to the Default View

Adding a file size column to a SharePoint Online document library can be accomplished using PowerShell as well. Before you begin, you will need to have the PnP PowerShell module installed on your computer and be connected to your SharePoint Online site using the Connect-PnPOnline cmdlet.

Here is the PnP PowerShell to include the “File Size” field in the default view of a SharePoint Online document library (If it’s not already added!).

# Parameter $SiteURL = "https://crescent.sharepoint.com/sites/Retail" $ListName = "Documents" $ColumnName = "FileSizeDisplay" #InternalName Try < # Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Interactive #Get the List Default View $List = Get-PnPList -Identity $ListName -Includes DefaultView #Get the List View from the list $ListView = Get-PnPView -List $ListName -Identity $List.DefaultView.Title #Check if view doesn't have the column already If($ListView.ViewFields -notcontains $ColumnName) < #Add Column to View $ListView.ViewFields.Add($ColumnName) $ListView.Update() Invoke-PnPQuery Write-host -f Green "Column '$ColumnName' Added to View!" >else < Write-host -f Yellow "Column '$ColumnName' Already Exists in View!" >> catch

My other post on getting the size of a file using PowerShell: How to Get File Size using PowerShell in SharePoint Online?