SharePoint column formatting examples

In this SharePoint Online tutorial, we will see, sharepoint column formatting examples and sharepoint column formatting JSON examples.

We will see, how to do column formatting in a modern list in SharePoint Online Office 365. As we know Microsoft provided many new features on the SharePoint modern page, this is one of the good features in SharePoint Online modern lists.

We can’t see this feature on SharePoint classic page.

SharePoint column formatting

SharePoint Column formatting does not affect data in lists or libraries. It changes the display of lists/libraries with the various colors, icons, font effects, etc. For this, we have to construct a JSON object to describe the elements that are displayed in the browser.

Read: SharePoint modern list view customization example

SharePoint column formatting examples

Let us see an example of SharePoint Online modern list column formatting.

Step 1: Log in to the SharePoint Online Office 365 site -> Go to Site Contents -> Create a list as per the below screenshot.

sharepoint modern list column formatting
sharepoint modern list column formatting

Step 2: Next click on any column in the SharePoint Online list and go to Column settings -> Format this column

sharepoint column formatting examples
sharepoint column formatting examples

Step 3: Once you click on Format this column, you will get default background colors to set in your list column.

sharepoint online modern list column formatting
sharepoint online modern list column formatting

Step 4: You can choose any other colors as per the requirement and next click on the Save button.

sharepoint online modern list column formatting examples
sharepoint online modern list column formatting examples

Step 5: This is the view of my SharePoint Online list after column formatting.

sharepoint column formatting examples
sharepoint column formatting examples

Step 6: The same steps I have applied for the status column where you can set the color as per the list status value.

sharepoint column formatting json examples
sharepoint column formatting json examples

Step 7: Below is the screenshot of my SharePoint Online list column where I change the colors as per the status value.

sharepoint jsom column formatting
sharepoint jsom column formatting

Step 8: Below is the final list after I applied the colors in the SharePoint Online list view. We can also apply the condition using code.

sharepoint modern list column formatting examples
sharepoint modern list column formatting examples

In this one simple example, we saw how to work with sharepoint column formatting.

Read: SharePoint jslink Examples

SharePoint column formatting JSON examples

Let us see a few examples of sharepoint column formatting JSON examples and I have taken mostly from GitHub.

Microsoft also allows us to customize columns in SharePoint lists and libraries by using column formatting with JSON. By using JSON we can format text, date, people, number and choices field, etc SharePoint list column types.

Now, let us see a few SharePoint column formatting JSON examples.

For this example, we created a list having the title, StartDate, TotalNo.of days, Assigned To, and Status column. When we entered some data initially by default list will show you like this.

sharepoint column formatting
sharepoint column formatting

Example-1: SharePoint column formatting JSON Title Column

For this first, we have to click on the Title field. then go to the Column setting. Select Format this column. Then go to Advanced mode. Now just put JSON code.

sharepoint column formatting examples
Title Column Format with JSON

To preview your formatting, click on Preview. To save, select Save. By Switch to design mode, you can reset your display to default mode.

In the above example, you can clearly see how the title column format. The simplest way to format a column is to place the value inside the <div/> element. Here are the codes:

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "@currentField"
}

Read SharePoint Online List Web Part

Example-2: SharePoint column formatting JSON Number

This example will show you using conditional formatting, how a number column is formatted with JSON. when the value of the current field is less than or equal to 10 then it will highlight the value of the field. And it will be normal when the value is greater than 10.

Similarly, go to advance mode. Apply JSON there. The field will become like this:

sharepoint column formatting json
sharepoint column formatting json number field

Follow this below code for formatting a number column using conditional statement:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "attributes": {
      "class": "=if(@currentField <= 10,'sp-field-severity--warning', '')"
    },
    "children": [
      {
        "elmType": "span",
        "style": {
          "display": "inline-block",
          "padding": "0 4px"
        },
        "attributes": {
          "iconName": "=if(@currentField <= 10,'Error', '')"
        }
      },
      {
        "elmType": "span",
        "txtContent": "@currentField"
      }
    ]
  }

Read SharePoint Text Web Part

Example-3: SharePoint column formatting JSON choice column example

You can also apply conditional formatting to the SharePoint choice column. Here we use the status as the choice column.

In this example, You can see the choices of the status column are formatted according to the values. Here we apply the CSS classes like sp-field-severity–good, sp-field-severity–low, sp-field-severity–warning, sp-field-severity–Severewarning for completed, On Going, Started, Not Started respectively.

You can apply this example or you can put your own value according to your requirement. This will help you to distinguish the severity of different levels with icons.

Similarly, go to advance mode. Apply JSON there. The field will become like this:

sharepoint column formatting json conditional choice column example
SharePoint Choice Column Format with JSON

Follow this below code for formatting a Choice column using a conditional JSON statement:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField == 'Completed', 'sp-field-severity--good', if(@currentField == 'On Going', 'sp-field-severity--low', if(@currentField == 'Started', 'sp-field-severity--warning', 'sp-field-severity--severeWarning'))) + ' ms-fontColor-neutralSecondary'"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": "=if(@currentField == 'Completed', 'CheckMark', if(@currentField == 'On Going', 'Forward', if(@currentField == 'Started', 'Error', 'Warning')))"
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}

Read SharePoint Online Events Web Part

Example-4: SharePoint column formatting json date examples

In this example, it will show you how the color of the Start Date will change after applying JSON.

*The color will be changed if the start date is not the same or before the current date then it will be formatted as color otherwise, it displays as normal. Here we use @now for resolving the current date/time, and use color code to display the previous date/time.(i.e, today’s date 4/23/2021).

For this formatting, go to advance mode. Then save it. Then the field will become like this:

sharepoint column formatting json date examples
sharepoint column formatting json date example

Follow this below code for formatting a Choice column using a conditional JSON statement:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "color": "=if([$StartDate] <= @now, '#DE3163', '')"
  }
}

In the above example, the color of the date field will be changed when it is the same as or previous date of the current date. You can modify the color code, as per your requirement.

Read SharePoint Group Calendar Web Part

Example-5: SharePoint column formatting JSON person column

In this formatting, we can able to add a button in the people field. This example also helps you to render a quick action that links to this field.

After applying JSON, the Assign To(people type column) will convert like the below screen:

People Column JSONFormat
People Column Format with JSON

Follow this below code for formatting a people column using a conditional JSON statement.

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "children": [
        {
            "elmType": "span",
            "style": {
                "padding-right": "8px"
            },
            "txtContent": "@currentField.title"
        },
        {
            "elmType": "a",
            "attributes": {
                "iconName": "Mail",
                "class": "sp-field-quickActions",
                "href": {
                    "operator": "+",
                    "operands": [
                        "mailto:",
                        "@currentField.email",
                        "?subject=Task status&body=Hey, how is your task coming along?.\r\n---\r\n",
                        "@currentField.title",
                        "\r\nClick this link for more info. http://contoso.sharepoint.com/sites/ConferencePrep/Tasks/Prep/DispForm.aspx?ID=",
                        "[$ID]"
                    ]
                }
            }
        }
    ]
}

In the above example, the <div/> element work as a parent element. It contains two child elements, one is <span/> element, which contains the person’s details, and another <a/> element is contained the quick actions for email sending(‘mailto‘).

Now You can check the differences between column formatting with JSON and the default column in SharePoint List.

sharepoint column formatting json examples
sharepoint column formatting json examples

This is another example of how SharePoint Online modern list column formatting works.

Read SharePoint Image Gallery Web Part

SharePoint Online List Formatting

We will discuss everything about SharePoint Online list formatting. Like conditional formatting in SharePoint list columns, conditional formatting with multiple conditions in SharePoint Online list columns.

We will see a few examples to add conditional formatting to a choice, date, and boolean columns in the modern SharePoint Online list.

Formatting a view or column is only available on the modern SharePoint list or SharePoint document library. But, it is not available on the classic SharePoint sites.

Overall we will see here, SharePoint Online list column formatting as well as SharePoint Online list view formatting.

What is Conditional Formatting in the SharePoint Online List?

  • Conditional Formatting options are available in the SharePoint Online list or library. We can customize the fields to be displayed in the SharePoint Online list or library.
  • There are two things that we can format in the Modern SharePoint Online list or library. They are,
    • Columns
    • Views
  • When we format a Column, we are just color-coding the given column information, which displays the items in the list or library with various icons, fonts, colors, etc.,
  • When we format a View, we are just color-coding the rows of information, which displays the items in the list or library with various icons, fonts, colors, etc.,
  • Formatting a Column or View in the modern SharePoint list or library will not affect any data in the list or library.

Read SharePoint Online List Permissions

Use Conditional Column Formatting to customize the SharePoint Online List

Let us see how we can use Conditional column formatting to customize or format the SharePoint Online list or library,

To Format a Column, follow the below steps:

  • Open the SharePoint Online list, and expand the column that you want to format or color code. Then select the Column settings and click on the Format this column option as shown below:

In this example, I have selected the AssignedTo column, to color code or format the column that has empty values in the field.

SharePoint Online List Column Formatting
SharePoint Online List Column Formatting
  • In the Format columns properties pane, Select or choose the Conditional formatting option and Click on the Manage rules.
List Column Formatting in SharePoint Online
List Column Formatting in SharePoint Online
  • In the Conditional formatting edit rule, Apply the condition if the AssignedTo column is equal to empty values then display the list items with the selected color.
  • We can change the styles to show the list items by selecting the styles icon.
  • Click on the Save button to save your changes.

In the below screenshot, you can see that the AssignedTo column that has an empty value has color-coded with the blue color.

List Column Formatting in the SharePoint Online
List Column Formatting in the SharePoint Online

This is how we can use conditional column formatting to customize or format the SharePoint Online list.

Read SharePoint Online list view

Use Conditional View Formatting to customize the SharePoint Online List

Let us see how we can use Conditional View formatting to customize or format the SharePoint Online list or library,

To Format a View, follow the below steps:

  • Open the SharePoint Online list, and expand the All items or the Current View that you want to format or color code. Then select the Format Current View option as shown below:

In this example, I am going to color code or format the row that is Assigned to the user name called Bijay Kumar Sahoo.

SharePoint Online List view Formatting
SharePoint Online List view Formatting
  • We also have an option to select List layout or Gallery layout under the Format view option.
  • In the Format View properties pane, Select or choose the Conditional formatting option and Click on the Manage rules.
List View Formatting in SharePoint Online
List View Formatting in SharePoint Online
  • In the Conditional formatting edit rule, Apply the condition if the AssignedTo column is equal to mentioned user name then displays the list items with the chosen color.
  • We can change the styles to show the list items by selecting the styles icon.
  • Click on the Save button to commit your changes.

In the below screenshot, you can see that the AssignedTo column that is assigned to the mentioned user has color-coded with the Purple color.

List View Formatting in the SharePoint Online
List View Formatting in the SharePoint Online

This is how we can use conditional view formatting to customize or format the SharePoint Online list.

Read SharePoint Highlighted content web part

SharePoint Online List Column Conditional formatting examples

Let us see how to apply conditional column formatting to different column types, we can apply column formatting for a choice column, date column boolean column, with multiple conditions in the SharePoint Online list.

Follow the below headings which is an example of SharePoint Online Column conditional Formatting based on the column data types.

Example-1: Add conditional formatting to a choice column in a SharePoint Online list

Let us see how can we add conditional formatting to a choice column in a SharePoint Online list,

To Format a Choice type Column, follow the below steps:

  • Open the SharePoint Online list, and expand the choice column that you want to format or color code. Then select the Column settings and click on the Format this column option as shown below:

In this example, I have selected the TrackTaskStatus which is of type choice column, here based on the task status-completed, in progress, and pending we can highlight or color code and displays the list items that are presented in the list.

conditional formatting to a choice column in a SharePoint Online list
conditional formatting to a choice column in a SharePoint Online list

In the Format columns properties pane, Scroll and select or choose the Conditional formatting option and Click on the Manage rules.

conditional formatting to a choice column in SharePoint Online list
conditional formatting to a Choice column in the SharePoint Online list
  • Select +Add rule and apply the following rule, If the TrackTasksStatus is equal to Completed then it displays the List item in Green color.
conditional formatting to a choice column in the SharePoint Online list
conditional formatting to a choice column in the SharePoint Online list
  • Select the Styles icon and Click on the More styles, Under Icon, select the check icon.
  • Click on the Save button to commit your changes.
conditional formatting to a choice column in modern SharePoint list
conditional formatting to a choice column in a modern SharePoint list
  • Again Select the +Add rule, If the TrackTasksStatus is equal to InProgress then it displays the List item in Orange color.
conditional formatting to a choice column in the modern SharePoint Online list
conditional formatting to a choice column in the modern SharePoint Online list
  • Select the Styles icon and Click on the More styles, Under Icon, select the Progress icon.
  • Click on the Save button to commit your changes.
conditional formatting to a choice column in SharePoint list
conditional formatting to a choice column in the SharePoint list
  • Again Select the +Add rule, If the TrackTasksStatus is equal to Pending then it displays the List item in Rose color.
conditional formatting to a choice column in the modern SharePoint list
conditional formatting to a choice column in the modern SharePoint list
  • Select the Styles icon and Click on the More styles, Under Icon, select the Error icon.
  • Click on the Save button to commit your changes.
conditional formatting to a choice column SharePoint Online list
conditional formatting to a choice column SharePoint Online list

In the below screenshot, you can see that the TrackTaskStatus column has color-coded based on the task status-completed, in progress, and pending and displays the list item highlighted.

conditional formatting to a choice column in modern SharePoint list example
conditional formatting to a choice column in modern SharePoint list example

This is how to add conditional formatting to a choice column in the Modern SharePoint Online list.

Read SharePoint Hero Web Part

Example-2: Add conditional formatting to a date column in a SharePoint Online list

Let us see how to add conditional formatting to a date column in a SharePoint Online list,

To Format a date type Column, follow the below steps:

  • Open the SharePoint Online list, and expand the date column that you want to format or color code. Then select the Column settings and click on the Format this column option as shown below:

In this example, I have selected the EndDate which is of type date column, here we can highlight or color code and display the list items presented in the list based on today’s date or we can mention a specific date.

conditional formatting to a date column in a SharePoint Online list
conditional formatting to a date column in a SharePoint Online list

In the Format columns properties pane, Scroll and select or choose the Conditional formatting option and Click on the Manage rules.

conditional formatting to a date column in SharePoint Online list
conditional formatting to a date column in the SharePoint Online list
  • Select +Add rule, Select the Comparison, we can compare the date selected is equal to, is not equal to, is before, is after, is on or before, is on or after, and is between. Select any one of these comparisons and compare it with today’s date or a specific date.
  • Click on the Save button to commit your changes.

In the below screenshot, you can see that the EndDate column has color-coded based on the is before comparison with today’s date and displays the list item as highlighted.

conditional formatting to a date column in a SharePoint Online list example
conditional formatting to a date column in a SharePoint Online list example
  • We will also see an example based on the is between comparison for the DueDate column. It will color code the list item that is in between the mentioned date as below.
  • Click on the Save button to commit your changes.
conditional formatting to a date column in SharePoint Online list example
conditional formatting to a date column in SharePoint Online list example

This is how to add conditional formatting to a date column in the Modern SharePoint Online list.

Read Customize SharePoint site page

Example-3: Add conditional formatting to a boolean column in a SharePoint Online list

Let us see how can we add conditional formatting to a boolean column in a SharePoint Online list,

To Format a boolean type Column, follow the below steps:

  • Open the SharePoint Online list, and expand the boolean column that you want to format or color code. Then select the Column settings and click on the Format this column option as shown below:

In this example, I have selected the TaskCompleted which is of type boolean column, here based on the task status-completed Yes/No we can highlight or color code and displays the list items that are presented in the list.

conditional formatting to a boolean column in a SharePoint Online list
conditional formatting to a boolean column in a SharePoint Online list

In the Format columns properties pane, select or choose the Conditional formatting option and Click on the Manage rules.

conditional formatting to a boolean column in SharePoint Online list
conditional formatting to a boolean column in the SharePoint Online list
  • Select the +Add rule, and apply the following rule, If the TasksCompleted is equal to Yes, then it displays the List item in Selected color as shown below:
  • Click on the Save button to commit your changes.
conditional formatting to a boolean column in modern SharePoint Online list
conditional formatting to a boolean column in the modern SharePoint Online list
  • Again Select the +Add rule, and apply the following rule, If the TasksCompleted is equal to No then it displays the List item in Selected color as shown below:
  • Click on the Save button to commit your changes.
conditional formatting to a boolean column in modern SharePoint list
conditional formatting to a boolean column in a modern SharePoint list

In the below screenshot, you can see that the TaskCompletedcolumn has color-coded based on the boolean value (Yes/No) and displays the list item highlighted.

conditional formatting to a boolean column in SharePoint list
conditional formatting to a boolean column in the SharePoint list

This is how can we add conditional formatting to a boolean column in a SharePoint Online list.

Example-4: Add conditional formatting with multiple conditions in a SharePoint Online list

Let us see how can we add conditional formatting with multiple conditions in a SharePoint Online list,

To Format a Conditional Column formatting with multiple conditions, follow the below steps:

  • Open the SharePoint Online list, and expand the column that you want to format or color code with multiple conditions. Then select the Column settings and click on the Format this column option as shown below:

In this example, I have selected the AssignedTo which is of type People column, here based on the task status-completed Yes/No we can compare add two conditions and highlight or color code, and displays the list items that are presented in the list.

conditional formatting with multiple conditions in a SharePoint Online list
conditional formatting with multiple conditions in a SharePoint Online list

In the Format columns properties pane, select or choose the Conditional formatting option and Click on the Manage rules.

conditional formatting with multiple conditions in SharePoint Online list
conditional formatting with multiple conditions in the SharePoint Online list
  • Select the +Add rule, and apply the following rule, If the AssignedTo is equal to Mentioned user And If the TasksCompleted is equal to Yes, then it displays the List item in Selected color as shown below:
  • Select +Add condition, to add And if / Or if conditions.
  • Click on the Save button to commit your changes.

In the below screenshot, you can see that If the AssignedTo is equal to Mentioned user And If the TasksCompleted is equal to Yes then it displays the list item highlighted in the AssignedTo column.

conditional formatting with multiple conditions in SharePoint Online list example
conditional formatting with multiple conditions in SharePoint Online list example

This is how can we add conditional formatting with multiple conditions in a SharePoint Online list.

Read How to Customize SharePoint Modern list form using JSON

Edit or delete conditional formatting rules in a SharePoint Online list

Let us see how to Edit or delete conditional formatting rules in a SharePoint Online list,

  • Open the SharePoint Online list, and expand the column that you want to edit or delete the conditional formatting rule.
  • Then select the Column settings and click on the Format this column option as shown below:
Edit or delete conditional formatting rules in a SharePoint Online list
Edit or delete conditional formatting rules in a SharePoint Online list

In the Format columns properties pane, Scroll and select or choose the Conditional formatting option and Click on the Manage rules.

Edit or delete conditional formatting rules in SharePoint Online list
Edit or delete conditional formatting rules in the SharePoint Online list
  • Select the Conditional rule and click on the ellipsis menu, Select the Edit rule to edit the rule, and also select the delete rule to delete the conditional rule.
  • We also can change the order of the conditional rule by selecting Move Up and Move down options.
Edit or delete conditional formatting rules in modern SharePoint Online list
Edit or delete conditional formatting rules in the modern SharePoint Online list

This is how to edit or delete conditional formatting rules in a SharePoint Online list.

Column Formatting SharePoint online document library

Let us see how we can use column formatting to customize or format the SharePoint Online document library,

To Format a Column, follow the below steps:

  • Open the SharePoint Online document library, and expand the column that you want to format or color code. Then select the Column settings and click on the Format this column option as shown below:
  • In this example, I have selected the Employee Id column, to color code or format the column that has empty values in the field.
column formatting sharepoint document library
column formatting SharePoint document library
  • In the Format columns properties pane, Select or choose the Conditional formatting option and Click on the Manage rules.
sharepoint document library column formatting
SharePoint document library column formatting
  • In the Conditional formatting edit rule, Apply the condition if the Employee Id column is equal to empty values then display the list items with the selected color.
  • We can change the styles to show the list items by selecting the styles icon.
  • Click on the Save button to save your changes.
sharepoint document library column formatting example
SharePoint document library column formatting example
  • In the below screenshot, you can see that the Employee Id column that has an empty value has color-coded with the purple color.
Example of sharepoint document library column formatting
Example of SharePoint document library column formatting

This is how we can use conditional column formatting to customize or format the SharePoint Online document library.

Edit or delete conditional Column formatting rules in a SharePoint Online document library

Let us see how to Edit or delete column conditional formatting rules in a SharePoint Online document library,

  • Open the SharePoint Online document library, and expand the column that you want to edit or delete the conditional formatting rule.
  • Then select the Column settings and click on the Format this column option as shown below:
column formatting sharepoint online document library
column formatting SharePoint online document library
  • In the Format columns properties pane, Scroll and select or choose the Conditional formatting option and Click on the Manage rules.
sharepoint online document library column formatting
SharePoint Online document library column formatting
  • Select the Conditional rule and click on the ellipsis menu, Select the Edit rule to edit the rule, and also select the delete rule to delete the conditional rule.
  • We also can change the order of the conditional rule by selecting Move Up and Move down options.
Edit or delete conditional Column formatting rules in a SharePoint Online document library
Edit or delete conditional Column formatting rules in a SharePoint Online document library

This is how to edit or delete conditional formatting rules in a SharePoint Online document library.

You may like the following SharePoint tutorials:

I hope this SharePoint tutorial explains, how to implement column formatting in SharePoint Online modern list, sharepoint column formatting json examples, and sharepoint column formatting examples.

  • How do I get items in a list to display in a custom format? I want to display certified mail tracking IDs as #### #### #### #### #### instead of simply ###################.

  • >