SharePoint Formatting JSON Examples

Formatting SharePoint forms can significantly enhance user experience and improve data input accuracy. JSON (JavaScript Object Notation) plays a crucial role in this process, allowing for precise control over form elements. Let's delve into SharePoint form formatting using JSON, exploring key aspects and providing practical examples.

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

SharePoint's JSON formatting offers a powerful way to customize the appearance and behavior of forms. It enables you to create responsive, visually appealing, and user-friendly forms that align with your organization's branding and improve data collection efficiency.

Customize SharePoint Forms with JSON
Customize SharePoint Forms with JSON

Understanding SharePoint JSON Formatting

SharePoint JSON formatting uses JSON syntax to define the appearance and behavior of form fields. It supports various properties, including background color, text color, font size, and more. Understanding the basics of JSON and SharePoint's JSON object model is essential for effective form formatting.

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

JSON objects in SharePoint consist of key-value pairs, where keys are property names, and values are the corresponding property values. For instance, to change the background color of a field, you would use the 'backgroundColor' key with the desired color value.

JSON Formatting Basics

SharePoint Page Section Templates Explained
SharePoint Page Section Templates Explained

Before diving into examples, let's cover some fundamental JSON formatting concepts:

  • Properties: JSON objects in SharePoint consist of properties that define the appearance and behavior of form fields. Properties can be nested to apply styles to child elements.
  • Values: Property values can be simple (like color codes) or complex (like arrays or objects).
  • Selectors: Selectors target specific elements in the form. They use a syntax similar to CSS selectors.

JSON Formatting Examples

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

Now that we've covered the basics, let's explore some JSON formatting examples to illustrate how to apply styles to SharePoint forms.

1. **Changing field background color:**

<?json
{
  "elmType": "span",
  "style": {
    "background-color": "#f0f0f0"
  }
}
?>

This JSON snippet changes the background color of all text fields in a form to light gray (#f0f0f0).

How to Personalize SharePoint for Users
How to Personalize SharePoint for Users

2. **Applying conditional formatting:**

<?json
{
  "elmType": "span",
  "style": {
    "color": "=if([$Title] eq 'New', 'red', 'black')"
  }
}
?>

This example applies red text color to the 'Title' field when its value is 'New' and black color otherwise.

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
How to track documents in SharePoint using Document ID feature | SharePoint Maven
How to track documents in SharePoint using Document ID feature | SharePoint Maven
Store and Reuse Document Templates in SharePoint
Store and Reuse Document Templates in SharePoint
Editing a Form: InfoPath
Editing a Form: InfoPath
SharePoint Content Types - BoostSolutions
SharePoint Content Types - BoostSolutions
The knowledge base Sharepoint intranet homepage
The knowledge base Sharepoint intranet homepage
Client Challenge
Client Challenge
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
15 Modern SharePoint Intranet Site Examples for 2026 — Origami
15 Modern SharePoint Intranet Site Examples for 2026 — Origami
How to create a Document Set in SharePoint Online | SharePoint Maven
How to create a Document Set in SharePoint Online | SharePoint Maven
SharePoint design examples - Content Formula
SharePoint design examples - Content Formula
the shareholders agreement is shown in this document, which includes two separate sections and one section
the shareholders agreement is shown in this document, which includes two separate sections and one section
How to Do Branching in Forms
How to Do Branching in Forms
SharePoint Page Design | ShortPoint Template Library
SharePoint Page Design | ShortPoint Template Library
Top 12 SharePoint Web Parts for a Powerful Intranet
Top 12 SharePoint Web Parts for a Powerful Intranet
HR SharePoint Site Template | ShortPoint Template Library
HR SharePoint Site Template | ShortPoint Template Library
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
Booking Form Builder | SaaS Admin Dashboard UIUX by Be Confidency on Muzli
Booking Form Builder | SaaS Admin Dashboard UIUX by Be Confidency on Muzli
SharePoint Wireframing to Mockup–How to Guide
SharePoint Wireframing to Mockup–How to Guide
an image of a web page with the words welcome and email in blue, green and white
an image of a web page with the words welcome and email in blue, green and white

Advanced JSON Formatting Techniques

SharePoint JSON formatting offers more advanced techniques to create complex and dynamic forms. Let's explore some of these techniques with examples.

Using Functions and Operators

SharePoint JSON supports various functions and operators to create dynamic and responsive forms. Functions like 'if', 'concat', and 'length' can be used to apply conditional styles, combine text, or check field values. Operators like 'eq', 'ne', 'gt', and 'lt' can be used to compare values.

For instance, to apply a red background to a field when its length exceeds 50 characters:

<?json
{
  "elmType": "span",
  "style": {
    "background-color": "=if(length([$Title]) gt 50, 'red', 'transparent')"
  }
}
?>

Customizing Field Labels

JSON formatting also allows you to customize field labels, making them more descriptive or adding icons for better usability.

To add an icon to a field label:

<?json
{
  "elmType": "span",
  "style": {
    "padding-right": "10px"
  },
  "txtContent": "=if([$Title] eq 'New', '🚀', '')"
}
?>

This example adds a smiley face (😀) icon to the 'Title' field label when its value is 'New'.

SharePoint JSON formatting opens up a world of possibilities for creating engaging and efficient forms. By mastering JSON formatting, you can significantly enhance the user experience and improve data collection in your SharePoint environment.

As you continue exploring SharePoint form formatting, don't hesitate to experiment with different properties, selectors, and techniques. The more you practice, the more proficient you'll become in creating visually appealing and functional forms that meet your organization's unique needs.