I have created a modern list in SPO with JSON conditional formatting on the row and view levels.

One conditional formatting snippet I've added hides the cell text (row level) based on the current user. But I would like to also hide the column header text as well and cannot figure out how to do this.

  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "display": "=if(@me == '[email protected]','','none')"

Similarly, I would like to format the column header to have a line break in case the title is long. This could be done with on-premise using CSS but again I have not found a way to do this in JSON. The actual column text can be JSON formatted to break but I can't do it at the column heading level. Simply adding a BR tag or \n\r (or its HTML-encoded equivalent) doesn't do anything.

Any insight would be welcome.


1 Answer 1


This is a known limitation of JSON formatting in SharePoint.

You cannot format the column headers using JSON formatting in SharePoint online.

  • Thank you Ganesh - so is there an option aside from JSON that can be used to format the column headers? May 7, 2021 at 19:28
  • Do you want to hide the column for one specific user or are there any other conditions based on those you want to hide the column? Can you please explain your requirements, maybe based on that I can suggest a workaround if any. May 9, 2021 at 13:22
  • Also you can check this view formatting sample for custom column headers. You can use the conditions like you are already using in view formatting. But it's drawback is you loose all the SharePoint default functionalities like sorting/filtering, context menu, etc. May 9, 2021 at 13:26
  • Hi Ganesh, Thanks for the sample - this is actually very similar to what we would like to implement since some of the column headers are long and we would like to force them into two lines (i.e. "Really long column header" into: Really long column header But the restrictions in terms of not being able to sort/filter/etc. will not be acceptable as the users like the ability to manipulate data. The second issue is indeed the ability to hide columns based on users. I don't think SPO has the ability to link a view to users/groups. So I use JSON to hide the data itself based on login. May 10, 2021 at 15:05
  • 1
    Thank you very much for your help Ganesh. I will poll our users regarding the classic experience. I wish the API would allow us access to the column header itself in the same way we can access the individual column elements (using indexes). May 13, 2021 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.