When it comes to customizing SharePoint list forms, JSON formatting has emerged as a powerful tool. It allows you to transform the default, often bland, user interfaces into engaging and user-friendly experiences. One of the key aspects of JSON formatting is understanding how to format the JSON body, which is the heart of your customization.

In this article, we'll delve into the intricacies of SharePoint list form JSON body formatting. We'll explore what it is, why it's important, and provide practical examples to help you get started. By the end, you'll have a solid understanding of how to format JSON bodies to create stunning SharePoint list forms.

Understanding SharePoint List Form JSON Body Formatting
JSON (JavaScript Object Notation) formatting in SharePoint allows you to customize the appearance and behavior of list forms. The JSON body is the core of this formatting, containing the rules and properties that define how your list form will look and function.

Formatting the JSON body involves structuring this data in a specific way to achieve the desired outcome. It's like writing a recipe: if you follow the instructions (the JSON body formatting) correctly, you'll get a delicious dish (a beautifully customized SharePoint list form).
Why JSON Body Formatting Matters

JSON body formatting is crucial for several reasons. Firstly, it enables you to create visually appealing forms that align with your organization's branding. This consistency can enhance user experience and professionalism.
Secondly, it allows you to control the behavior of form elements. You can make fields required, hide them based on conditions, or even create dynamic forms that change based on user input. This level of control can improve data accuracy and user satisfaction.
Getting Started with JSON Body Formatting

Before you dive into JSON body formatting, ensure you have the right tools. You'll need a text editor (like Visual Studio Code or Notepad++) to write your JSON, and a browser that supports modern SharePoint features (like Microsoft Edge or Google Chrome).
To start, navigate to your SharePoint list and click on 'Edit' in the command bar. Then, click on 'Format this form' to open the formatting pane. Here, you can switch to 'Advanced mode' to start writing your JSON body.
Formatting the JSON Body: Key Elements

Now that we've covered the basics, let's dive into the key elements of JSON body formatting. Understanding these elements will help you create complex and engaging SharePoint list forms.
Here are some of the key elements you'll work with:




















- Properties: These define the appearance and behavior of form elements. For example, you can use properties to change the background color, font size, or make a field required.
- Rules: Rules allow you to control the behavior of form elements based on conditions. For instance, you can hide a field if another field's value is 'Yes'.
- Layouts: Layouts determine the structure of your form. You can create complex layouts with tabs, sections, or even conditional layouts that change based on user input.
Working with Properties
Properties are the building blocks of JSON body formatting. They allow you to customize the appearance and behavior of form elements. Here's a simple example of how to change the background color of a field:
"bgColor": "rgb(240, 240, 240)"
In this example, the background color of the field is set to a light gray. You can replace 'rgb(240, 240, 240)' with any valid color value.
Creating Rules for Conditional Behavior
Rules allow you to control the behavior of form elements based on conditions. Here's an example of how to hide a field if another field's value is 'Yes':
"hideIf": "@currentWeb.Title eq 'Yes'"
In this example, the field will be hidden if the value of the 'Title' field in the current web is 'Yes'. You can replace 'Title' and 'Yes' with any valid field name and value.
Practical Examples: Formatting JSON Bodies
Now that we've covered the basics, let's look at some practical examples of JSON body formatting. These examples will help you understand how to apply what you've learned to create custom SharePoint list forms.
Creating a Custom Form Layout
One of the most common use cases for JSON body formatting is creating custom form layouts. Here's an example of how to create a form with two tabs:
{
"Principals": {
"rows": {
"fields": {
"Title": { "width": 300 },
"Description": { "width": 600 }
}
},
"tabs": {
"Tab 1": {
"fields": {
"Field 1": {},
"Field 2": {}
}
},
"Tab 2": {
"fields": {
"Field 3": {},
"Field 4": {}
}
}
}
}
}
In this example, the form has a 'Principals' section with two fields: 'Title' and 'Description'. It also has two tabs: 'Tab 1' and 'Tab 2', each containing two fields.
Creating Conditional Form Behavior
JSON body formatting also allows you to create dynamic forms that change based on user input. Here's an example of how to show or hide a field based on the value of another field:
{
"fields": {
"ShowHide": {
"showIf": "@currentField eq 'Show'"
}
}
}
In this example, the field 'ShowHide' will only be shown if the value of the current field is 'Show'. You can replace 'ShowHide' and 'Show' with any valid field name and value.
JSON body formatting in SharePoint list forms opens up a world of possibilities for customization. Whether you're looking to create visually appealing forms, improve user experience, or enhance data accuracy, JSON body formatting is a powerful tool in your arsenal.
So, what are you waiting for? Start exploring the possibilities of SharePoint list form JSON body formatting today. Your users will thank you, and you'll be well on your way to becoming a SharePoint customization guru.