Recently, while working on one of the client’s requirements, I encountered a problem adding the lookup column value to the JSON Code while formatting the SharePoint list. So, I thought I would share my experience in this blog post.
In this tutorial, I will explain how to add a lookup value to the SharePoint column formatting JSON background color. Also, I will describe how to add additional columns coming from a lookup column.
SharePoint Lookup Column Formatting using JSON Background Color
To explain this, I will represent the SharePoint list with a few columns, including the lookup column, as shown in the image below.
| Column Name | Data Type |
| Title | Single line of text (Default) |
| Predecessors | Look Up [Get information from Title] |
| Project Start Date | Date and Time |
| Project End Date | Date and Time |
| Priority | Choice |

Requirement: Here, I wanted to format the background color if the Title column value is equal to the Predecessors column value.
Follow the steps:
- In the SharePoint list, click on +Add view -> Provide View name -> Tap the Create button to add a new view. A new view of the SharePoint list has now been created.

- To the newly created view [Look Up view] -> Click on the drop-down -> Select Format current view to open the Format view pane.

- Next, click the Advanced mode link in the Format view pane.

- Now, copy and paste the JSON code provided below, where we can format the list view background color for the items with the title ‘Predecessors’.
Important:
In the given code, replace the code with column internal names of your SharePoint list.
To add a lookup column, such as “Predecessors,” into a SharePoint list formatting, you need to provide it with .lookupValue [$Predecessors.lookupValue].
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"debugMode": true,
"txtContent": "[$Predecessors]",
"additionalRowClass": "=if([$Predecessors.lookupValue] == '[$Title]', 'sp-field-severity--severeWarning', '')"
}
- Then, click the Save button and close the pane. You can see the changes to your SharePoint list view, which is formatted with the background color.
Refer to the image below:

Check out Customize SharePoint List Form Layout using JSON Code
Example 2: SharePoint List JSON Formatting with Lookup Column
In this example, I will demonstrate how to format the additional lookup column using JSON code.
Scenario:
Here, I wanted to format the Predecessors: Title, an additional column from Predecessors [Look Up]. Where, format the font color of the lookup column value, if the Predecessors Title column contains Evaluation as a value.
You can see that I have used the SharePoint list above to represent this example.

Steps to follow:
- On the SharePoint column header, choose Column settings ->click on Format this column.

- In the Format view pane, click on the Advanced mode link to insert the code.

- Then, add the json code provided below. Click on the Save button.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"debugMode": true,
"txtContent": "[$Predecessors_x003a__x0020_Title]",
"style": {
"color": "=if([$Predecessors_x003a__x0020_Title] == 'Evaulation', '#FF0000', '#0000FF')"
}
}

Output:

This is how to format a lookup column using JSON in SharePoint.
Conclusion
I hope that this tutorial has helped you understand how to add a lookup column to JSON code to format the SharePoint list view and learn how to format the SharePoint lookup column.
You may also like the following tutorials:
- Create a Custom ID Column in SharePoint List using JSON
- Gantt Chart View in SharePoint Online Modern List Using JSON
- SharePoint Calculated Column to Extract Email from Person Field
- How to Format a SharePoint Online List Column using JSON?

Preeti Sahu is an expert in Power Apps and has over six years of experience working with SharePoint Online and the Power Platform. She is the co-author of Microsoft Power Platform: A Deep Dive book. As a Power Platform developer, she has worked on developing various tools using Power Apps and Power Automate. She also makes Microsoft 365 videos and shares them on YouTube.