SharePoint Column Formatting: JSON Examples You Can Copy
Column formatting lets you change how a SharePoint list or library column looks without touching the data. I use it on almost every list I build, to turn plain text into coloured status pills, overdue warnings and progress bars. Here are the examples I reuse, ready to paste.
1. Where to paste the JSON
- Open your list or library.
- Click the column header, then Column settings, then Format this column.
- Switch to Advanced mode (at the bottom of the panel).
- Paste the JSON, check the Preview, then click Save.
To undo it, open the same panel and choose Clear, or delete the JSON. The data in the column is never changed, only how it is displayed.
2. How the JSON works in 60 seconds
Every format describes an HTML element. The main properties are elmType (div, span, a), txtContent (the text shown), style (CSS), attributes (such as class or href) and children (elements inside it).
Values starting with = are expressions. @currentField is the value of the column you are formatting, @now is the current date and time, and [$InternalName] reads another column in the same row. Expressions support if(), comparisons (==, <, >), && and ||, and string joining with +.
The first line of every example is the $schema. Leave it in: it gives you error hints in the editor.
3. Coloured status pill for a Choice column
SharePoint has built-in severity classes that follow your theme, so you don't need hex colours. This turns Done green, In progress amber, Blocked red and anything else a neutral grey. Change the choice names to match yours.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if(@currentField == 'Done', 'sp-field-severity--good', if(@currentField == 'In progress', 'sp-field-severity--warning', if(@currentField == 'Blocked', 'sp-field-severity--blocked', 'sp-field-severity--low'))) + ' ms-fontColor-neutralPrimary'"
},
"style": { "padding": "2px 10px", "border-radius": "12px", "display": "inline-block" }
}The classes I use most are sp-field-severity--good (green), --low (blue), --warning (amber), --severeWarning (orange) and --blocked (red).
4. Highlight overdue dates
Add this to a Date column. Any date earlier than now shows with the orange severity style, and future dates stay plain.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if(@currentField < @now, 'sp-field-severity--severeWarning', '')"
}
}5. Progress bar for a Number column
This works for a Number column holding 0 to 100. The inner bar is as wide as the value, inside a grey track.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": { "width": "120px", "background-color": "#e1e1e1" },
"children": [
{
"elmType": "div",
"txtContent": "=@currentField + '%'",
"style": {
"width": "=@currentField + '%'",
"background-color": "#0078d4",
"color": "white",
"font-size": "11px",
"padding-left": "4px",
"box-sizing": "border-box"
}
}
]
}If you use a Percentage column, the stored value is 0 to 1, so change both width values to =@currentField * 100 + '%'.
6. Yes/No column with an icon
Icons come from the Fluent icon set that SharePoint already loads. Set the class to ms-Icon ms-Icon--IconName. This shows a green tick for Yes and a red cross otherwise. If your column is a Yes/No type, compare against true rather than 'Yes' and check the Preview.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": { "display": "flex", "align-items": "center" },
"children": [
{
"elmType": "span",
"attributes": {
"class": "='ms-Icon ms-Icon--' + if(@currentField == 'Yes', 'CheckMark', 'Cancel')"
},
"style": { "margin-right": "6px", "color": "=if(@currentField == 'Yes', '#107c10', '#a4262c')" }
},
{ "elmType": "span", "txtContent": "@currentField" }
]
}7. A button or link built from another column
Use elmType a to make a link, and [$ID] or any internal column name to build the address. This example opens a page for the current item in a new tab. Replace the address with your own.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "Open",
"attributes": {
"href": "='https://contoso.sharepoint.com/sites/Projects/SitePages/Project.aspx?id=' + [$ID]",
"target": "_blank",
"class": "ms-fontColor-themePrimary"
}
}Always add target set to _blank for external links, and only link to places your users can already reach.
8. Fix it when it doesn't work
- Add "debugMode": true at the top level. SharePoint then shows the exact error beside the cell.
- Check the quotes. JSON needs double quotes around keys and values, and expressions use single quotes inside them.
- Use the column's internal name in [$Name]. A column called Due Date is usually [$Due_x0020_Date].
- Remember formatting is display only. It does not change filters, sorting, or what a Power Automate flow reads.
- Formatting applies in modern views. If you see no change, check you are not in the classic experience.
Once you are comfortable with these, combine them: a pill, an icon and a link in one column is just children inside a single parent element.
Want this done for you?
I build this for clients every week. Book a free 30-minute call and I'll tell you exactly what your team needs.