Leveraging JSON Formatting for SharePoint Lookup Columns
In the dynamic world of SharePoint, lookup columns play a pivotal role in maintaining data consistency and integrity. While SharePoint offers a range of out-of-the-box features, sometimes you might need to go beyond the basics to achieve the desired look and feel. This is where JSON formatting comes into play, offering a powerful tool to customize and enhance your SharePoint lookup columns.
Understanding JSON Formatting in SharePoint
JSON (JavaScript Object Notation) formatting is a way to customize the appearance and behavior of SharePoint list views, including lookup columns. It allows you to apply styles, add conditional formatting, and even create custom views. By leveraging JSON formatting, you can transform your SharePoint lists from plain and simple to engaging and informative.
Why Use JSON Formatting for Lookup Columns?
- Improved Readability: JSON formatting enables you to change the text color, font size, and background color of lookup columns, making them more readable and visually appealing.
- Conditional Formatting: You can apply conditional formatting to lookup columns to highlight important information or draw attention to specific items.
- Custom Icons: JSON formatting allows you to add custom icons to lookup columns, providing a quick visual reference for users.
- Responsive Design: With JSON formatting, you can ensure that your lookup columns display well on various devices and screen sizes.
Getting Started with JSON Formatting for Lookup Columns
To begin using JSON formatting for SharePoint lookup columns, you'll first need to enable the "Modern Experience" for your SharePoint site. Once enabled, you can start applying JSON formatting to your lookup columns. Here's a step-by-step guide to help you get started:

- Navigate to the list or library containing the lookup column you want to format.
- Click on the "Settings" gear icon and select "List settings" or "Library settings".
- Under the "Columns" section, click on the name of the lookup column you want to format.
- Scroll down to the "Formatting" section and click on the "JSON formatting" link.
- Here, you can enter your JSON code or use the "JSON formatting snippet" panel to build your formatting rules. You can also use the "JSON formatting preview" panel to see how your changes will look in real-time.
- Once you're satisfied with your formatting, click "OK" to save your changes.
JSON Formatting Examples for Lookup Columns
To give you an idea of what's possible with JSON formatting for SharePoint lookup columns, here are a few examples:
Changing Text Color Based on Status
In this example, we'll change the text color of a lookup column based on the status of an item. Here's the JSON code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "span",
"txtContent": "@currentField",
"style": {
"color": "=if(@currentField == 'Completed', 'green', if(@currentField == 'In Progress', 'orange', 'red'))"
}
}
Adding Custom Icons to a Lookup Column
In this example, we'll add custom icons to a lookup column based on the type of an item. Here's the JSON code:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "span",
"attributes": {
"iconName": "=if(@currentField == 'Type A', 'A', if(@currentField == 'Type B', 'B', 'C'))"
},
"style": {
"padding-right": "5px"
}
}
Conclusion
JSON formatting offers a wealth of possibilities for customizing and enhancing your SharePoint lookup columns. By leveraging JSON formatting, you can create more engaging and informative lists that cater to the unique needs of your organization. Whether you're looking to improve readability, apply conditional formatting, or add custom icons, JSON formatting has you covered. So why not give it a try and see what you can achieve with your SharePoint lookup columns?



![Display SharePoint List Items in a SPFX Web Part [Tabular Format]](https://i.pinimg.com/originals/ef/45/21/ef45215299f094b62fbf5fd9eee232aa.jpg)



















