SharePoint List Form JSON Formatting

SharePoint list forms are a powerful tool for managing and organizing information within your SharePoint environment. However, the default forms may not always align with your specific needs or branding. This is where JSON formatting comes into play, offering a flexible and efficient way to customize the appearance and behavior of your SharePoint list forms.

SharePoint List Form Formatting with JSON & flow approvals (2)
SharePoint List Form Formatting with JSON & flow approvals (2)

JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. In SharePoint, JSON formatting allows you to apply custom styles, add conditional formatting, and even modify the behavior of form fields, enhancing the user experience and improving data accuracy.

Customize Modern SharePoint List Forms Tutorial | JSON Formatting, Validations
Customize Modern SharePoint List Forms Tutorial | JSON Formatting, Validations

Understanding JSON Formatting in SharePoint List Forms

Before diving into the specifics of JSON formatting, it's essential to understand the basics. JSON formatting is applied to SharePoint list forms using the 'Formatting' column property. This property accepts JSON objects that define the visual and behavioral aspects of the form fields.

Learn How To Customize A Sharepoint List Form
Learn How To Customize A Sharepoint List Form

JSON objects consist of key-value pairs, where keys are strings and values can be strings, numbers, objects, arrays, booleans, or null. In the context of SharePoint, these keys correspond to the properties of the form fields that you want to customize, such as 'fillColor', 'fontWeight', or 'required'.

JSON Formatting Syntax

SharePoint List Title Column [Remove or Hide Title Column With Examples]
SharePoint List Title Column [Remove or Hide Title Column With Examples]

JSON syntax is straightforward and consists of the following rules:

  • Data is in key-value pairs, separated by commas.
  • Keys must be strings, enclosed in double quotes.
  • Values can be strings (enclosed in double quotes), numbers, objects (enclosed in curly braces), arrays (enclosed in square brackets), booleans (true or false), or null.
  • Curly braces hold objects, and square brackets hold arrays.
  • Indentation is used to indicate structure, but not required.

JSON Formatting Examples

Customize SharePoint Forms with JSON
Customize SharePoint Forms with JSON

Here are a few simple examples of JSON formatting to illustrate its syntax and functionality:

  • {"fillColor": "#FF0000", "fontWeight": "bold"} - This JSON object sets the fill color to red and the font weight to bold.
  • {"visible": {"operator": "!=", "value": "Yes"}} - This JSON object hides the field when the value is not "Yes".
  • {"style": {"color": "green", "font-size": "18px"}} - This JSON object changes the text color to green and the font size to 18 pixels.

Applying JSON Formatting to SharePoint List Forms

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

Now that you understand the basics of JSON formatting, let's explore how to apply it to SharePoint list forms. The process involves editing the list form and applying the JSON formatting to the desired fields.

To access the JSON formatting options, click on the 'Formatting' column property in the list settings. This will open the 'Formatting' pane, where you can enter your JSON code. You can also use the 'Advanced Mode' option to view and edit the JSON code directly.

Add Conditional Formatting to a SharePoint Online List
Add Conditional Formatting to a SharePoint Online List
How to customize Forms in SharePoint Lists 📃
How to customize Forms in SharePoint Lists 📃
Customizing SharePoint List Forms in InfoPath 2010
Customizing SharePoint List Forms in InfoPath 2010
How to List Unique Permissions for Files and Folders on a SharePoint Site
How to List Unique Permissions for Files and Folders on a SharePoint Site
Connect SharePoint List To Excel - Part 2
Connect SharePoint List To Excel - Part 2
Learn How To Implement Sharepoint List Validation
Learn How To Implement Sharepoint List Validation
Why You Should Never Embed Document Libraries and Lists into SharePoint Pages
Why You Should Never Embed Document Libraries and Lists into SharePoint Pages
SharePoint Page Section Templates Explained
SharePoint Page Section Templates Explained
How to Create a Custom List in SharePoint | Beginner Tutorial
How to Create a Custom List in SharePoint | Beginner Tutorial
Editing a Form: InfoPath
Editing a Form: InfoPath
SharePoint Content Types - BoostSolutions
SharePoint Content Types - BoostSolutions
📊 How to create Charts in Microsoft SharePoint Lists
📊 How to create Charts in Microsoft SharePoint Lists
How to implement Document Management System in SharePoint using Content Types | SharePoint Maven
How to implement Document Management System in SharePoint using Content Types | SharePoint Maven
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
How to Personalize SharePoint for Users
How to Personalize SharePoint for Users
How to track documents in SharePoint using Document ID feature | SharePoint Maven
How to track documents in SharePoint using Document ID feature | SharePoint Maven
SharePoint Sites Naming Convention Best Practices
SharePoint Sites Naming Convention Best Practices
Store and Reuse Document Templates in SharePoint
Store and Reuse Document Templates in SharePoint
How to Create a Custom Permission Level in SharePoint
How to Create a Custom Permission Level in SharePoint
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

Customizing Form Field Appearance

JSON formatting allows you to customize the appearance of form fields in various ways. For example, you can change the background color, text color, font size, and font weight. You can also add icons, borders, and other visual elements to enhance the form's appearance.

Here's an example of JSON code that changes the background color of a field to light blue and the text color to dark blue:

{"backgroundColor": "#ADD8E6", "color": "#00008B"}

Adding Conditional Formatting

Conditional formatting allows you to apply different styles based on the value of a field. This can be useful for highlighting important information or indicating the status of a record. For example, you can display a red background when the 'Status' field is set to 'Overdue'.

Here's an example of JSON code that applies conditional formatting based on the value of the 'Status' field:

{"backgroundColor": {"operator": "==", "value": "Overdue", "fill": "#FF0000"}}

Modifying Form Field Behavior

In addition to customizing the appearance of form fields, JSON formatting also allows you to modify their behavior. For example, you can make a field required, hide it, or disable it. You can also add validation rules to ensure that users enter valid data.

Here's an example of JSON code that makes a field required and adds a validation rule to ensure that the value is a valid email address:

{"required": true, "validation": {"type": "email", "message": "Please enter a valid email address."}}

In conclusion, JSON formatting is a powerful tool for customizing SharePoint list forms. It allows you to apply custom styles, add conditional formatting, and modify the behavior of form fields, enhancing the user experience and improving data accuracy. By leveraging the flexibility and efficiency of JSON formatting, you can create SharePoint list forms that meet the specific needs of your organization and align with your branding. So, start exploring the world of JSON formatting today and unlock the full potential of your SharePoint list forms!