SharePoint Online List Forms JSON Formatting

In this SharePoint Online tutorial, we will learn how we can customize or format the SharePoint Online list forms using JSON formatting.

We can display the columns in a section-wise or group-wise manner which makes us user-friendly to use the SharePoint Online list forms. We can add one or more sections with fields to customize or format the SharePoint Online list form.

We will also learn how we can format or customize the header, footer, and body of the SharePoint List Forms using JSON formatting. Here we have covered the below topics:

  • Customize the SharePoint Online List Form Header using JSON formatting
  • Customize the SharePoint Online List Form Body using JSON formatting
  • Customize the SharePoint Online List Form Footer using JSON formatting
  • SharePoint Online List Column JSON formatting examples
  • SharePoint column JSON formatting to a Title Column
  • Add JSON formatting to a Person column in a SharePoint Online list
  • Add JSON formatting to a Date column in a SharePoint Online list
  • Add JSON formatting to a Choice column in a SharePoint Online list

Customize the SharePoint Online List Form Header using JSON formatting

Let us see how we can customize or format the SharePoint Online list form header using JSON formatting,

To achieve this, follow the below steps:

  • Open the SharePoint Online list form that you want to customize or format using JSON formatting.
  • Add a + New item to display the SharePoint Online list fields in a detailed view.
  • In the New item window, Expand the Edit form icon and click on the Configure Layout option as displayed below:
SharePoint Online List Forms JSON Formatting
SharePoint Online List Form Header using JSON formatting
  • Once the configure layout option is selected, In the Apply formatting to option select the Header option from the dropdown.
List Form Header using JSON formatting in SharePoint Online
List Form Header using JSON formatting in SharePoint Online
  • In the Formatting code option, apply or paste the below-mentioned JSON formatting code. To Preview the code click on the Preview button.
  • Click on the Save button to save the changes.
{
    "elmType": "div",
    "attributes": {
        "class": "ms-borderColor-neutralTertiary"
    },
    "style": {
        "width": "100%",
        "margin-bottom": "15px",
        "background-color": "purple"
    },
    "children": [
        {
            "elmType": "div",
            "style": {
                "display": "flex",
                "align-items": "center"
            },
            "children": [
                {
                    "elmType": "div",
                    "style": {
                        "flex": "none",
                        "padding": "0px",
                        "padding-left": "10px",
                        "height": "40px",
                        "color": "white"
                    }
                }
            ]
        },
        {
            "elmType": "div",
            "attributes": {
                "class": "ms-fontColor-themePrimary ms-borderColor-themePrimary ms-fontWeight-bold ms-fontSize-xl ms-fontColor-neutralSecondary–hover ms-bgColor-themeLight–hover"
            },
            "style": {
                "box-sizing": "border-box",
                "width": "100%",
                "text-align": "center",
                "padding": "21px 12px",
                "overflow": "hidden",
                "color": "white"
            },
            "children": [
                {
                    "elmType": "div",
                    "txtContent": "Task Details"
                }
            ]
        }
    ]
}

In the below screenshot, you can see that the Header is added to the SharePoint Online list form.

SharePoint Online List Forms JSON Formatting
SharePoint Online List Forms JSON Formatting

This is how to customize or format the SharePoint Online list form header using JSON formatting.

Read SharePoint list View Tutorial

Customize the SharePoint Online List Form Body using JSON formatting

Let us see how to customize or format the SharePoint Online list form body using JSON formatting,

To achieve this, follow the below steps:

  • Open the SharePoint Online list form that you want to customize or format using JSON formatting.
  • Add a + New item to display the SharePoint Online list fields in a detailed view.
  • In the New item window, Expand the Edit form icon and click on the Configure Layout option as displayed below:
Customize the SharePoint Online List Form Body using JSON formatting
Modern SharePoint Online List Form Header using JSON formatting
  • The below mentioned is the JSON structure to display the columns or fields in the SharePoint Online list in a section-wise manner or group-wise manner.
  • We can add one or more sections with fields to customize or format the SharePoint Online list form.
{
    "sections": [
        {
            //We can mention the display name for the section
            "displayname": "",
            "fields": [
                //We can add the fields that we want to display in this section
                "Title"
            ]
        },
        {
            //give a display name for the section
            "displayname": "",
            "fields": [
                //reference your fields here using their display name
            ]
        }
    ]
}
  • Once the configure layout option is selected, In the Apply formatting to option select the Body option from the dropdown.
List Form body using JSON formatting in SharePoint Online
List Form body using JSON formatting in SharePoint Online
  • In the Formatting code option, apply or paste the below-mentioned JSON formatting code. To Preview the code click on the Preview button.
  • Click on the Save button to save the changes.
{
    "sections": [
        {
            "displayname": "Tasks Assigned",
            "fields": [
                "EmployessName",
                "TaskDescription",
                "AssignedTasks"
            ]
        },
        {
            "displayname": "Tasks Period",
            "fields": [
                "StartDate",
                "EndDate",
                "DueDate"
            ]
        },
        {
            "displayname": "Tasks Status",
            "fields": [
                "TrackTasksStatus",
                "TaskCompleted"
            ]
        }
    ]
}

In the below screenshot, you can see the SharePoint Online list form is displaying the field in a section-wise manner.

SharePoint Online List Form Body Customization using JSON formatting
List Form Body using JSON formatting in the SharePoint Online

We can also see that if we try to edit the columns in the form, the fields are displaying the section-wise manner as shown below:

List Form Body using JSON formatting in the SharePoint Online example
List Form Body using JSON formatting in the SharePoint Online example

This is how to customize or format the SharePoint Online list form body using JSON formatting.

Read Customize SharePoint List Forms with PowerApps

Customize the SharePoint Online List Form Footer using JSON formatting

Let us see how to customize or format the SharePoint Online list form footer using JSON formatting.

To achieve this, follow the below steps:

  • Open the SharePoint Online list form that you want to customize or format using JSON formatting.
  • Add a + New item to display the SharePoint Online list fields in a detailed view.
  • In the New item window, Expand the Edit form icon and click on the Configure Layout option as displayed below:
Customize SharePoint Online List Form Footer using JSON formatting
Customize SharePoint Online List Form Footer using JSON formatting
  • Once the configure layout option is selected, In the Apply formatting to option select the Footer option from the dropdown.
How to Customize SharePoint Online List Form Footer using JSON formatting
List Form footer using JSON formatting in the SharePoint Online
  • In the Formatting code option, apply or paste the below-mentioned JSON formatting code. To Preview the code click on the Preview button.
  • Click on the Save button to save the changes.
{
    "elmType": "div",
    "style": {
        "height": "24px",
        "width": "100%",
        "color": "#fff",
        "font-size": "15px",
        "border-top": "5px solid #eee",
        "background-color": "Purple",
        "padding": "10px"
    },
    "children": [
        {
            "elmType": "div",
            "style": {
                "width": "100%",
                "padding-top": "10px",
                "height": "24px"
            },
            "children": [
                {
                    "elmType": "a",
                    "txtContent": "='Task Review for ' + [$Title]",
                    "attributes": {
                        "target": "_blank",
                       "href": "='https://aka.ms/task?review=' + [$Tasks]"
                    },
                    "style": {
                        "color": "white"
                    }
                }
            ]
        }
    ]
}

In the below screenshot, you can see that the Footer is added to the SharePoint Online list form.

SharePoint Online List Forms JSON Formatting example
SharePoint Online List Forms JSON Formatting example

This is how to customize or format the SharePoint Online list form footer using JSON formatting.

Read Create a canvas app in PowerApps from a SharePoint list

SharePoint Online List Column JSON formatting examples

Let us see a few examples of Column formatting by using JSON formatting, we can apply column formatting for a title column, choice column, and person column in the SharePoint Online list.

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

SharePoint column JSON formatting to a Title Column

Let us see how we can use JSON column formatting to customize or format the Title column in the SharePoint Online list,

To Format a Title type Column by JSON formatting, follow the below steps:

  • Open the SharePoint Online list, and expand the Title 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 Title column, to color code or format the column.

SharePoint column JSON formatting to a Title Column
SharePoint column JSON formatting to a Title Column
  • In the Format columns properties pane, Select or choose Advanced mode as shown below:
SharePoint online column JSON formatting to a Title Column
SharePoint column JSON formatting to Title Column
  • In the Formatting code option, apply or paste the below-mentioned JSON formatting code. To Preview the code click on the Preview button.
  • Click on the Save button to save the changes.
  • By Switching to design mode, we can reset the list items to display in a default mode.
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "style": { "color": "Purple"},
  "elmType": "div",
  "txtContent": "@currentField"
}

In the below screenshot, you can see that the Title column has been color-coded with the Purple color.

SharePoint online JSON formatting to a Title Column
SharePoint column JSON formatting to Title Column example

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

Add JSON formatting to a Person column in a SharePoint Online list

Let us see how we can use JSON column formatting to customize or format the Person column in the SharePoint Online list,

To Format a Person type Column by JSON formatting, follow the below steps:

  • Open the SharePoint Online list, and expand the Person column that you want to format or color code. Then select the Column settings and click on the Format this column option.
  • In the Format columns properties pane, Select or choose Advanced mode as shown below:

In this example, I have selected the EmployeesName column, which is of type person column to color code or format the SharePoint Online list items.

Add JSON formatting to a Person column in a SharePoint Online list
SharePoint column JSON formatting to People Column example
  • In the Formatting code option, apply or paste the below-mentioned JSON formatting code. To Preview the code click on the Preview button.
  • Click on the Save button to save the changes.
  • By Switching to design mode, we can reset the list items to display in a default mode.
{
    "$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": "People"}    
        }
    ]
}

In the below screenshot, you can see that the EmployeesName column has been formatted with the people icon.

Add JSON formatting to a Person column in a SharePoint list
SharePoint column JSON formatting to a People Column example

This is how we can use JSON column formatting to customize or format the People Column in the SharePoint Online list.

Add JSON formatting to a Date column in a SharePoint Online list

Let us see how we can use JSON column formatting to customize or format the Date column in the SharePoint Online list,

To Format a Date type Column by JSON formatting, 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.
  • In the Format columns properties pane, Select or choose Advanced mode as shown below:

In this example, I have selected the JoiningDate column, which is of type date column to color code or format the SharePoint Online list items. The Joining Date will be color-coded if it is the same or before the current date.

Add JSON formatting to a Date column in a SharePoint Online list
Add column JSON formatting to a Date column in a SharePoint Online list
  • In the Formatting code option, apply or paste the below-mentioned JSON formatting code. To Preview the code click on the Preview button.
  • Click on the Save button to save the changes.
  • By Switching to design mode, we can reset the list items to display in a default mode.
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "color": "=if([$JoiningDate] <= @now, '#FF33CA', '')"
  }
}

In the below screenshot, you can see that the Joining Date column has been formatted based on the condition applied.

How to add JSON formatting to a Date column in a SharePoint Online list
Add column JSON formatting to a Date column in a SharePoint Online list example

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

Add JSON formatting to a Choice column in a SharePoint Online list

Let us see how we can use JSON column formatting to customize or format the Choice column in the SharePoint Online list,

To Format a Choice type Column by JSON formatting, 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.
  • In the Format columns properties pane, Select or choose Advanced mode as shown below:

In this example, I have selected the Department column, which is of type choice column to color code or format the SharePoint Online list items. The Departement Column will be color-coded based on the condition.

Add JSON formatting to a Choice column in a SharePoint Online list
SharePoint column JSON formatting to a choice Column example
  • In the Formatting code option, apply or paste the below-mentioned JSON formatting code. To Preview the code click on the Preview button.
  • Click on the Save button to save the changes.
  • By Switching to design mode, we can reset the list items to display in a default mode.

In this example, we apply the CSS classes like sp-field-severity–goodsp-field-severity–warningsp-field-severity–Severewarning for the  Departments like FinanceTeam, Python Team and SharePoint Team respectively.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField == 'FinanceTeam', 'sp-field-severity--good', if(@currentField == 'Python Team', 'sp-field-severity--warning', if(@currentField == 'SharePoint Team', 'sp-field-severity--severeWarning','sp-field-severity--blocked'))) + ' ms-fontColor-neutralSecondary'"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      }},
     
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}

In the below screenshot, you can see that the Department column has been formatted based on the condition applied.

How to add JSON formatting to a Choice column in a SharePoint Online list
Add column JSON formatting to a choice column in a SharePoint Online list

This is how to use JSON column formatting to customize or format the Choice column in the SharePoint Online list.

In this SharePoint Online customization tutorial, we learned how to customize and format the SharePoint Online list form using JSON with examples.

  • SharePoint Online List Forms JSON Formatting
  • Customize the SharePoint Online List Form Header using JSON formatting
  • Customize the SharePoint Online List Form Body using JSON formatting
  • Customize the SharePoint Online List Form Footer using JSON formatting
  • SharePoint Online List forms JSON Formatting examples
  • SharePoint list forms JSON examples
  • Customize modern SharePoint Online list forms JSON
  • SharePoint Online List Column JSON formatting examples
  • SharePoint column JSON formatting to a Title Column
  • Add column JSON formatting to a Person column in a SharePoint Online list
  • Add column JSON formatting to a Date column in a SharePoint Online list
  • Add column JSON formatting to a Choice column in a SharePoint Online list

You may like the following SharePoint tutorials:

  • In the section, “Customize the SharePoint Online List Form Body using JSON formatting”, is there a way to add text outside of the display name? I’ve created an ‘Agreement’ section in my own form, but need to find a way to also include the policies that one would be agreeing to by filling out the section. Any way to implement this would be greatly appreciated. Thank you!

  • >