SharePoint List Form Formatting JSON Examples

SharePoint list form formatting can significantly enhance the user experience and improve data input accuracy. One powerful way to achieve this is by utilizing JSON formatting. JSON (JavaScript Object Notation) allows you to customize the appearance and behavior of SharePoint list forms, making them more intuitive and engaging. In this article, we'll explore SharePoint list form formatting using JSON, with practical examples to help you get started.

SharePoint List JSON Form Formatting & Validations (3)
SharePoint List JSON Form Formatting & Validations (3)

Before delving into JSON formatting, ensure that your SharePoint list is set to allow JSON formatting. You can do this by clicking on the list settings gear icon, selecting 'List settings', then under 'Form settings', choose 'Enable JSON formatting'.

Customize SharePoint Forms with JSON
Customize SharePoint Forms with JSON

Understanding the Basics of JSON Formatting

JSON formatting in SharePoint is based on the modern experience. It uses a set of predefined properties and functions to style and control the behavior of list forms. Familiarizing yourself with these properties and functions is crucial for effective JSON formatting.

Display SharePoint List Items in a SPFX Web Part [Tabular Format]
Display SharePoint List Items in a SPFX Web Part [Tabular Format]

To apply JSON formatting, click on the list item or new item form, then select 'Format this web part' (or 'Format this item') from the command bar. This will open the 'Format web part' (or 'Format item') panel, where you can paste your JSON code.

JSON Formatting Properties

How to customize Forms in SharePoint Lists 📃
How to customize Forms in SharePoint Lists 📃

JSON formatting properties allow you to style various elements of the list form, such as background color, text color, font size, and more. Here's a simple example that changes the background color of a list item:

<?json<
{
  "backgroundColor": "#FFFF00"
}
</?>

In this example, replace `"#FFFF00"` with the desired background color code. You can find a list of predefined properties and their possible values in the SharePoint documentation.

JSON Formatting Functions

Editing a Form: InfoPath
Editing a Form: InfoPath

JSON formatting functions enable you to control the behavior of list forms, such as showing or hiding fields based on user input, displaying conditional content, and more. Here's an example that shows or hides a field based on the value of another field:

<?json<
{
  "field": {
    "Name": "MyField",
    "Show": "@currentWeb.Fields.getByName('MyConditionField').Value == 'Yes'"
  }
}
</?>

In this example, replace `'MyField'` and `'MyConditionField'` with the actual names of your fields. This function will show the 'MyField' field only when the 'MyConditionField' value is 'Yes'.

JSON Formatting Examples

Why You Should Never Embed Document Libraries and Lists into SharePoint Pages
Why You Should Never Embed Document Libraries and Lists into SharePoint Pages

Now that we've covered the basics, let's explore some practical JSON formatting examples to help you create more engaging and user-friendly SharePoint list forms.

Styling List Item Cards

How to Create a Custom List in SharePoint | Beginner Tutorial
How to Create a Custom List in SharePoint | Beginner Tutorial
Learn How To Implement Sharepoint List Validation
Learn How To Implement Sharepoint List Validation
How to track documents in SharePoint using Document ID feature | SharePoint Maven
How to track documents in SharePoint using Document ID feature | SharePoint Maven
User Interaction for Insurance Claim Management System
User Interaction for Insurance Claim Management System
Site Collections, Sites, Pages, Document Libraries, and Folders - putting it all together | SharePoint Maven
Site Collections, Sites, Pages, Document Libraries, and Folders - putting it all together | SharePoint Maven
InfoPath Formatting Rule
InfoPath Formatting Rule
an info sheet with instructions on how to use the email list for site inspections
an info sheet with instructions on how to use the email list for site inspections
Client Challenge
Client Challenge
Using SharePoint Online Document Libraries as a Document Management System
Using SharePoint Online Document Libraries as a Document Management System
The knowledge base Sharepoint intranet homepage
The knowledge base Sharepoint intranet homepage
Client Challenge
Client Challenge
ISO9001 2015 Purchasing Procedure Template Word
ISO9001 2015 Purchasing Procedure Template Word
Why you should never attach documents in a SharePoint list | SharePoint Maven
Why you should never attach documents in a SharePoint list | SharePoint Maven
Client Challenge
Client Challenge
two screens showing different types of information in the same language, and one with an arrow pointing
two screens showing different types of information in the same language, and one with an arrow pointing
ServiceNow Client Scripts
ServiceNow Client Scripts
a blank sign up sheet with lines on it
a blank sign up sheet with lines on it
two screens showing the different types of email and phone numbers on one screen, with text above them
two screens showing the different types of email and phone numbers on one screen, with text above them
How to Do Branching in Forms
How to Do Branching in Forms
Store and Reuse Document Templates in SharePoint
Store and Reuse Document Templates in SharePoint

JSON formatting allows you to style list item cards, making them more visually appealing and easier to navigate. Here's an example that changes the text color, font size, and adds a border to list item cards:

<?json<
{
  "style": {
    "spFieldQuery": {
      "color": "white",
      "font-size": "18px",
      "border": "1px solid black"
    }
  }
}
</?>

You can customize this example to suit your specific needs by modifying the color, font size, and border properties.

Conditional Formatting

Conditional formatting allows you to display different styles or content based on the value of a field. Here's an example that changes the background color of a list item based on the status of a 'Status' field:

<?json<
{
  "style": {
    "spFieldQuery": {
      "background-color": "@currentField == 'Completed' ? '#D1FAE5' : '@currentField == 'In Progress' ? '#FFFF00' : '#FFC7CE'"
    }
  }
}
</?>

In this example, replace the color codes and field names with your desired values. This function will apply different background colors to list items based on the status of the 'Status' field.

JSON formatting in SharePoint offers a wealth of possibilities for customizing list forms. By mastering the basics of JSON formatting properties and functions, you can create engaging, user-friendly, and efficient list forms that enhance the overall SharePoint experience. So go ahead, experiment with different styles and behaviors, and make your SharePoint lists truly your own!