Copilot 6 min read

How to Use Copilot to Write SharePoint Column Formatting JSON

Column formatting JSON is fiddly to write by hand: quotes, curly brackets, nested if statements. Copilot Chat will write it for you if you describe the look you want, and you fix it by telling Copilot what the preview shows. Here's the process, the prompt that got it unstuck in my demo, and a clean version of the JSON.

Key takeaways

  • SharePoint column formatting is a block of JSON pasted into Column settings, Format this column. It changes how values look in a view and never changes the data.
  • Copilot Chat can write the JSON from a plain description of the column, its values and the look you want, and it doesn't need a Microsoft 365 Copilot licence because the job uses no organisational data.
  • Paste each version into the formatting pane and select Preview before Save, then describe what's wrong in the next prompt.
  • In my demo, asking twice for a pill around the text only changed nothing. Telling Copilot it may need to take a different approach got working JSON on the next reply.
  • Choice columns don't need JSON for coloured pills: the Format this column pane has fill colours and pill styles built in.

To have Copilot write SharePoint column formatting JSON, describe the column, its values and the look you want in Copilot Chat, paste the JSON it returns into Format this column, select Preview, and tell Copilot what’s wrong until the preview looks right. In my demo it took seven prompts and a couple of number changes of my own to turn a plain Category column in a document library into coloured pills.

Column formatting only changes how a value is displayed in the view. The data underneath stays the same, and anyone who can create and manage views in the list can apply it. The video came from a newsletter subscriber asking how to style their managed metadata columns, and I recorded it in November 2024 with Copilot switched from Work to Web, the web-grounded chat that’s now Copilot Chat.

Before you start

  • Permission to manage views. Site owners have it, and so do members of a standard team site.
  • Copilot Chat is enough. Writing JSON doesn’t need your emails, files or meetings, so no Microsoft 365 Copilot licence is required (what each one can reach).
  • The column type and its exact values. Copilot writes conditions like “if the value equals Granite”, so give it the values as they appear.
  • Check whether you need JSON at all. For a Choice column, Format this column already offers fill colours and pill styles with no code. JSON earns its keep on text, managed metadata and other column types.

How do you get Copilot to write the JSON?

  1. Give Copilot the job and a reference. My first prompt told Copilot it was a SharePoint developer with experience customising list views and columns with JSON, and pointed it at a GitHub repository of formatting samples. Microsoft’s own samples are in the sp-dev-column-formatting repository.
  2. Ask for the specific result. “Can you write some JSON code to format a column that contains text values? I want to have the ability to have different colours for different string values.”
  3. Paste the JSON into the column. Select the column header, then Column settings, then Format this column, and paste it into the box. For a Choice column, select Advanced mode first.
  4. Select Preview, not Save. The pane shows the change on your real items without committing it. If Copilot used a placeholder value, swap in one of yours.
  5. Describe what you see in the next prompt. Say in plain words what’s wrong with the preview, paste the new version and preview again. Select Save when it’s right.

What happened in my demo

The first version only changed the text colour, using “High” as a placeholder. I swapped in Granite, one of my real categories, and the colour changed on preview. Asking for it to look “like the out of the box choice pills” put a background across the whole cell.

I asked twice more for the pill around the text only, and neither preview changed at all. The prompt that fixed it was “You may need to take a different approach. I want the pill around the text value only, not the whole cell.” The next version put a rounded pill around each value, and two more prompts added padding. Then I finished it by hand: left and right padding to 10, top and bottom to 6, and the border radius from 2 to 100 for fully rounded ends.

Here’s a clean version of where it ended up, written against Microsoft’s column formatting schema. Granite and Digital Services Initiative are values from my demo library. Swap in your own values and colours, and anything else gets the grey pill.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "txtContent": "@currentField",
      "style": {
        "display": "=if(@currentField == '', 'none', 'inline-block')",
        "padding": "6px 10px",
        "border-radius": "100px",
        "color": "#ffffff",
        "background-color": "=if(@currentField == 'Granite', '#5c5c5c', if(@currentField == 'Digital Services Initiative', '#0078d4', '#8a8886'))"
      }
    }
  ]
}

The pill sits on a span inside a div, so the colour wraps the text instead of filling the cell, and the display rule hides it when the column is empty.

Treat Copilot as the developer and yourself as the reviewer

You don’t need to understand JSON to start, but you do need to look at every preview and say plainly what’s wrong. “That fills the whole cell” gets you further than guessing at the code. In my demo, rewording the same request got nowhere twice, and telling Copilot its approach wasn’t working moved it on.

Read the code as it improves. After a few rounds you’ll recognise padding, border-radius and background-color, and a number change is quicker to make yourself than another prompt. Keep the finished JSON on your site, because @currentField means the same block works on any column with the same values.

Copilot in SharePoint can now apply formatting from the chat pane, which I show in creating and formatting a Microsoft List with Copilot in SharePoint. It needs a Microsoft 365 Copilot licence, and I still check the list every time because it has told me formatting was applied when it wasn’t. The Copilot Chat route works with any work account and leaves you JSON you can read and reuse.

Colours help people scan a view, but Copilot and search work from the values underneath, so get the metadata right first. Adding metadata columns to a library covers that side.

Frequently asked questions

Do I need a Microsoft 365 Copilot licence to have Copilot write column formatting JSON? No. Copilot Chat, included with eligible Microsoft 365 work accounts, can write it because the job uses no organisational data. Applying formatting from Copilot in SharePoint is different and needs the licence.

Why doesn’t my column formatting preview change? Check you pasted the whole block, including the $schema line, and that the values in the conditions match your column’s values exactly. Adding "debugMode": true to the JSON sends error messages and warnings to the browser console.

Which columns can’t be formatted? The file name column in a document library, retention labels, sealed columns and multi-line text with enhanced rich text. Managed metadata, choice, text, person, lookup and most other column types are supported.

Can I format a Choice column without writing JSON? Yes. Open Format this column and choose the pill or fill colour for each choice. For other columns, Conditional formatting then Manage rules sets a colour when a column equals a value.

Get these in your inbox. One email a week.

Practical thinking on organising your information and getting real work out of AI. Subscribers get the free SharePoint Skill course to start.